-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (79 loc) · 3 KB
/
gradle.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
101
name: Java CI with Gradle
# master 브랜치의 push와 pull로 CI가 작동
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
# 자신이 사용하는 자바 버전에 맞춰주자
java-version: '11'
distribution: 'temurin'
- uses : actions/checkout@v3
#1
# 디렉터리 생성
- run : mkdir ./src/main/resources/keys
- run : mkdir ./src/main/resources/firebase
# 이용하여서 설정 파일을 생성해줌 (github에 commit 되는게 아님!)
- run : touch ./src/main/resources/application.properties
- run : echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.properties
# google
- run : touch ./src/main/resources/google_client_key.json
- run : echo "${{ secrets.GOOGLE }}" > ./src/main/resources/google_client_key.json
# oauth
- run : touch ./src/main/resources/oauth.yml
- run : echo "${{ secrets.OAUTH }}" > ./src/main/resources/oauth.yml
# firebase
- run : touch ./src/main/resources/firebase/soonsool-firebase.json
- run : echo "${{ secrets.FCM }}" > ./src/main/resources/firebase/soonsool-firebase.json
# keys
- run : touch ./src/main/resources/keys/AuthKey_2RYD94LVWD.p8
- run : echo "${{ secrets.AUTHKEY }}" > ./src/main/resources/keys/AuthKey_2RYD94LVWD.p8
# gradlew에 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# gradlew 빌드
- name: Build with Gradle
run: ./gradlew clean build
# 빌드를 성공하면 해당 프로젝트를 zip로 만듬
# 이름은 run 에서 설정 가능
- name: Make zip file
run: zip -r ./soonsol.zip .
shell: bash
#2
# AWS 계정 설정
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
# 깃허브 Secret에 넣어둔 Access key
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# 깃허브 Secret에 넣어둔 Secret key
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# 깃허브 Secret에 넣어둔 Region
aws-region: ${{ secrets.AWS_REGION }}
#3
# 만들어 놓은 S3에 해당 zip 파일 저장
- name: Upload to S3
run: aws s3 cp --region ${{ secrets.AWS_REGION }} ./soonsol.zip s3://soonsool-back/soonsol.zip
#4
# AWS CodeDeploy에 배포
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws deploy create-deployment \
--application-name soonsool-project \
--deployment-group-name cicd-soonsool-prod \
--file-exists-behavior OVERWRITE \
--s3-location bucket=soonsool-back,bundleType=zip,key=soonsol.zip \
--region ${{ secrets.AWS_REGION }}