-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (90 loc) · 2.74 KB
/
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
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
102
103
104
105
106
107
108
109
110
111
112
113
name: CD
on:
push:
branches: [ develop ]
env:
S3_BUCKET_NAME: cecd1921-bucket
jobs:
build:
name: Code deployment
# 실행 환경
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Change to server directory # 'server' 디렉토리로 이동
run: cd server
shell: bash
- name: make application.yml
run: |
## create application.yml
mkdir -p ./src/main/resources
cd ./src/main/resources
if [ ! -f ./application.yml ]; then
touch ./application.yml
echo "${{ secrets.CD_APPLICATION }}" >> ./application.yml
else
echo "application.yml 파일이 이미 존재합니다."
fi
echo "${{ secrets.CD_APPLICATION }}" >> ./application.yml
cat ./application.yml
shell: bash
- name: Grant execute permission for gradlew
run: |
cd server
chmod +x gradlew
- name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
run: |
cd server
./gradlew build -x test
- name: Make Directory
run: |
cd server
mkdir -p deploy
- name: Copy Jar
run: |
cd server
cp ./build/libs/*.jar ./deploy
- name: Copy appspec.yml
run: |
cd server
cp appspec.yml ./deploy
- name: Copy script
run: |
cd server
cp ./scripts/*.sh ./deploy
- name: Make zip file
run: |
cd server
zip -r ./cecd-1921.zip ./deploy
shell: bash
- name: Configure AWS credentials
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
- name: Upload to S3
run: |
cd server
aws s3 cp --region ap-northeast-2 ./cecd-1921.zip s3://$S3_BUCKET_NAME/
- name: Change to server directory # Deploy 전에 server 디렉토리로 이동
run: cd server
shell: bash
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
run: |
aws deploy create-deployment \
--application-name cecd-1921-deploy \
--deployment-group-name cecd-1921-deploy \
--file-exists-behavior OVERWRITE \
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=cecd-1921.zip \
--region ap-northeast-2
shell: bash