-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (74 loc) · 3.15 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
name: tenten
on:
push:
branches:
- main
paths-ignore:
- 'README.md' # README.md 파일 변경을 무시
jobs:
build:
runs-on: ubuntu-latest # 우분투 설치
env:
SPRING_PROFILES_ACTIVE: ci
steps:
- name: Checkout
uses: actions/checkout@v3 # 코드 다운로드 / 적기 귀찮은 것들을 라이브러리(스크립트 모임) 형태로 제공하는 것이 actions 이다.
- name: Setup MySQL # mysql 설정
uses: samin/mysql-action@v1
with:
host port: 3306
container port: 3306
mysql database: 'tentendb'
mysql user: 'admin'
mysql password: 'root'
character set server: 'utf8'
- name: Set up JDK 17
uses: actions/setup-java@v3 # jdk 설치 / 버전마다 다른 jdk 설치 제공
with:
java-version: 17
distribution: oracle
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew # gradlew 실행권한 부여
- name: Build with Gradle
run: ./gradlew clean build # build 하기
id: buildAndTests
continue-on-error: true # 테스트에 실패해도 계속 로그찍기
- name: Archive test results if tests failed # 테스트가 실패하면 결과 아카이빙
if: steps.buildAndTests.outcome == 'failure'
uses: actions/upload-artifact@v2
with:
name: test-results # 해당 URL에 테스트 결과 아카이빙
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 -p 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: tenten-beanstalk # 엘라스틱 빈스톡 애플리케이션 이름
environment_name: Tenten-beanstalk-env-2 # 엘라스틱 빈스톡 환경 이름
version_label: tenten-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: deploy/deploy.zip # 배포패키지 경로
wait_for_environment_recovery: 300