-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (63 loc) · 2.66 KB
/
main.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
name: CICD
run-name: Running
on:
push:
branches:
- develop # develop이라는 브런치로 푸쉬했을 때 실행
- 'releases/**'
env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: app-release-files
AWS_CODE_BUCKET_NAME : s3-cicd-bucket # 기억해두라고 했던 버킷 이름
AWS_CODE_DEPLOY_APPLICATION: cd-application-cicd # 기억해두라고 했던 애플리케이션 이름
AWS_CODE_DEPLOY_GROUP: cd-publish-cicd # 기억해두라고 했던 배포 그룹 이름
jobs:
build-with-gradle:
runs-on: ubuntu-20.04 # ubuntu ver
steps:
- name: develop 브랜치로 이동
uses: actions/checkout@v3
with:
ref: develop
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Create application.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
# - name: create firebase key
# run: |
# cd ./src/main/resources
# ls -a .
# touch ./bangfer-firebase-key.json
# echo "${{ secrets.FIREBASE_KEY }}" > ./bangfer-firebase-key.json
# shell: bash
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "bangfer-firebase-key.json"
json: ${{ secrets.FIREBASE_KEY }}
dir: 'src/main/resources/'
- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew
- name: 프로젝트 빌드
run: ./gradlew clean build -x test
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY }}
- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ env.AWS_CODE_BUCKET_NAME }}/cicdDir/$GITHUB_SHA.zip
# - name: S3에 업로드
# run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://${{ env.AWS_CODE_BUCKET_NAME }}/cicdDir/$GITHUB_SHA.zip --source .
- name: EC2에 배포
run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=${{ env.AWS_CODE_BUCKET_NAME }},key=cicdDir/$GITHUB_SHA.zip,bundleType=zip