-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (67 loc) · 2.46 KB
/
github-actions.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
on:
push:
branches:
- main
env:
CODE_DEPLOY_APPLICATION_NAME: CatchRoom-deploy
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: CatchRoom-Codedeployment
MY_ENV_VARIABLE: 'my-value' # Here is where we add the new environment variable.
SLACK_WEBHOOK_URI: ${{ secrets.SLACK_WEBHOOK_URI }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'adopt' # or 'temurin' or 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Clean with Gradle
run: ./gradlew clean
- name: Build with Gradle
run: ./gradlew build --scan
# 전송할 파일을 담을 디렉토리 생성
- name: Make Directory for deliver
run: mkdir deploy
# Jar 파일 copy
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy/
- name: Copy appspec and deploy script
run: |
cp ./appspec.yml ./deploy/
cp ./deploy.sh ./deploy/
# 압축파일 형태로 전달
- name: Make zip file
run: zip -r -qq -j ./$GITHUB_SHA.zip ./deploy
# S3 Bucket으로 Upload
- name: Deploy
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
# S3 Bucket으로 copy
- name: Deliver to AWS S3
run: aws s3 cp --region ap-northeast-2 --acl private ./$GITHUB_SHA.zip s3://catchroom-bucket/
- name: Code Deploy
run: |
aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=catchroom-bucket,bundleType=zip,key=$GITHUB_SHA.zip
# 배포 성공시 슬랙 webhook
- name: Slack - Send Msg
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,job,commit,repo,author,took,ref
author_name: CatchRoom_BE
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URI}}
if: always()