-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (87 loc) · 3.38 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: study-hub
on:
push:
branches:
- main
# https://github.com/actions/setup-java
# actions/setup-java@v2는 사용자 정의 배포를 지원하고 Zulu OpenJDK, Eclipse Temurin 및 Adopt OpenJDK를 기본적으로 지원합니다. v1은 Zulu OpenJDK만 지원합니다.
jobs:
build:
runs-on: ubuntu-latest
env:
SPRING_PROFILES_ACTIVE: ci
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
JWT_SERCRET: ${{ secrets.JWT_SECRET }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MySQL #mysql 설정
uses: samin/mysql-action@v1
with:
host port: 3306
container port: 3306
mysql database: 'sh_db'
mysql user: 'admin'
mysql password: 'root'
character set server: 'utf8'
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu
- name: Permission
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
id: buildAndTests
continue-on-error: true # 테스트에 실패해도 계속 로그찍기
# # Jacoco 테스트 커버리지 결과 아카이빙
# - name: JaCoCo Code Coverage Report
# id: jacoco_reporter
# uses: PavanMudigonda/jacoco-reporter@v4.9
# with:
# coverage_results_path: build/reports/jacoco/test/jacocoTestReport.xml
# coverage_report_name: Coverage
# coverage_report_title: JaCoCo
# github_token: ${{ secrets.PAT }}
# skip_check_run: false
# minimum_coverage: 20
# fail_below_threshold: false
# publish_only_summary: false
- name: Archive test results if tests failed # 테스트가 결과 아카이빙
uses: actions/upload-artifact@v2
with:
name: test-results
path: |
**/build/reports/tests/test/
- name: Stop workflow if tests failed # 테스트가 실패하면 테스트 실패 로그 아카이빙 후 전체 플로우 종료
if: steps.buildAndTests.outcome == 'failure'
run: exit 1
# UTC가 기준이기 때문에 한국시간으로 맞추려면 +9시간 해야 한다
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"
- name: Show Current Time
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}"
# EB에 CD 하기 위해 추가 작성
- name: Generate deployment package
run: |
mkdir deploy
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: Studyhub # 엘리스틱 빈스톡 애플리케이션 이름!
environment_name: Studyhub-env-1 # 엘리스틱 빈스톡 환경 이름!
version_label: study-hub-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: deploy/deploy.zip