-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (76 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
# ์ํฌํ๋ก์ฐ์ ์ด๋ฆ ์ง์
name: Winey-Server CD
# ํด๋น workflow๊ฐ ์ธ์ ์คํ๋ ๊ฒ์ธ์ง์ ๋ํ ํธ๋ฆฌ๊ฑฐ๋ฅผ ์ง์
on:
push:
branches: [ main ] # main branch๋ก push ๋ ๋ ์คํ๋ฉ๋๋ค.
env:
S3_BUCKET_NAME: winey-s3
jobs:
build:
name: Code deployment
# ์คํ ํ๊ฒฝ
runs-on: ubuntu-latest
steps:
# 1) ์ํฌํ๋ก์ฐ ์คํ ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฒดํฌ์์ ํ์
- name: checkout
uses: actions/checkout@v3
# 2) JDK 11๋ฒ์ ์ค์น, ๋ค๋ฅธ JDK ๋ฒ์ ์ ์ฌ์ฉํ๋ค๋ฉด ์์
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
# 3) ํ๊ฒฝ๋ณ์ ํ์ผ ์์ฑ
- name: make application.properties ํ์ผ ์์ฑ
run: |
## create application.yml
mkdir ./src/main/resources
cd ./src/main/resources
# application.yml ํ์ผ ์์ฑ
touch ./application.yml
# GitHub-Actions ์์ ์ค์ ํ ๊ฐ์ application.yml ํ์ผ์ ์ฐ๊ธฐ
echo "${{ secrets.WINEY_APPLICATION }}" >> ./application.yml
# application.yml ํ์ผ ํ์ธ
cat ./application.yml
shell: bash
# ์ด ์ํฌํ๋ก์ฐ๋ gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle # ์ค์ application build(-x ์ต์
์ ํตํด test๋ ์ ์ธ)
run: ./gradlew build -x test
# ๋๋ ํ ๋ฆฌ ์์ฑ
- name: Make Directory
run: mkdir -p deploy
# Jar ํ์ผ ๋ณต์ฌ
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy
# appspec.yml ํ์ผ ๋ณต์ฌ
- name: Copy appspec.yml
run: cp appspec.yml ./deploy
# script files ๋ณต์ฌ
- name: Copy script
run: cp ./scripts/*.sh ./deploy
- name: Make zip file
run: zip -r ./winey_server.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: aws s3 cp --region ap-northeast-2 ./winey_server.zip s3://$S3_BUCKET_NAME/
# Deploy
- 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 winey-deploy
--deployment-group-name sopt-server-codedeploy-group
--file-exists-behavior OVERWRITE
--s3-location bucket=winey-s3,bundleType=zip,key=winey_server.zip
--region ap-northeast-2