-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (59 loc) · 2.38 KB
/
user-cd.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
# workflow의 이름
name: github-action-user-cd
# 해당 workflow가 언제 실행될 것인지에 대한 트리거 지정
# workflow 수동 실행
on:
workflow_dispatch:
inputs:
name:
description: 'CD를 수행하기 위하여 승인을 해주세요.'
required: true
default: 'CD를 수행하기 위한 Github Action 입니다.'
# 해당 yml 내에서 사용할 key - value
env:
PROJECT_NAME: user
# workflow는 한개 이상의 job을 가지며, 각 job은 여러 step에 따라 단계를 나눌 수 있습니다.
jobs:
build:
name: github-action-user-cd
runs-on: ubuntu-latest
steps:
# 작업에서 액세스 할 수 있도록 저장소를 체크아웃 해줌.
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
# ./gradlew 명령어를 수행 할 수 있도록 실행 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
# ./gradlew build 수행
- name: Build with Gradle
run: ./gradlew :user:clean :user:build
shell: bash
# user의 jar 파일과 appspec을압축
- name: Make zip file
run: |
files_to_compress="$(find user/build/libs/ -type f) appspec.yml scripts/deploy.sh"
archive_name="$GITHUB_SHA.zip"
zip -r "$archive_name" $files_to_compress
shell: bash
- name: Configure AWS credentials
uses: aws-action/configure-aws-credentials@v1
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-region: ${{secrets.AWS_REGION}}
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{secrets.S3_BUCKET_NAME}}/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy
run: |
aws deploy create-deployment \
--application-name ${{secrets.CODE_DEPLOY_NAME}} \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name ${{secrets.CODE_DEPLOY_GROUP_USER}} \
--file-exists-behavior OVERWRITE \
--s3-location bucket=${{secrets.S3_BUCKET_NAME}},bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip \
--region ${{secrets.AWS_REGION}}