-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) ยท 3.57 KB
/
deploy.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
name: Deploy
on:
push:
branches: ['main', 'develop']
env:
PROJECT_NAME: duaily-client
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code. # Repo checkout
uses: actions/checkout@v2
- name: Check Node v # Node v ํ์ธ
run: node -v
- name: Cache node modules # node modules ์บ์ฑ
uses: actions/cache@v1
with: # with ๊ตฌ๋ฌธ์ผ๋ก ์ค์ ํ ์ ์๋๋ฐ, path์ key๋ฅผ ๋ฐ๋์ ์ค์ ํด์ฃผ์ด์ผ ํจ
path: node_modules # ์ ์ฅํ๊ณ ๋ถ๋ฌ์ฌ ์บ์ ๋์ ํด๋
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} # ์ ์ฅํ๊ณ ๋ถ๋ฌ์ฌ ๋ ์๋ณํ ์ ์๋ ํค ๊ฐ
restore-keys:
| # ์บ์ key๊ฐ ์ผ์นํ๋ ๊ฒ์ด ์์ ๋, ์ฐจ์ ํ์ผ๋ก ์บ์ฑ ํด๋๋ฅผ ์ฐพ๋ key
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install Dependencies # ์์กด ํ์ผ ์ค์น
run: yarn install --frozen-lockfile
- name: Setting .env (Dev) # ํ๊ฒฝ๋ณ์ ์ธํ
(DEV)
if: contains(github.ref, 'develop')
run: echo "${{ secrets.REACT_ENV_DEV }}" >> .env
- name: Setting .env (Prod) # ํ๊ฒฝ๋ณ์ ์ธํ
(PROD)
if: contains(github.ref, 'main')
run: |
echo "${{ secrets.REACT_ENV }}" >> .env
- name: Build # React Build
run: yarn build
- name: zip create # zip ํ์ผ์ ๋ง๋ญ๋๋ค
run: zip -r ./$GITHUB_SHA.zip ./dist appspec.yml
shell: bash
- name: Configure AWS credentials (Dev) # AWS ์ธํ
(DEV)
if: contains(github.ref, 'develop')
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.AWS_REGION_DEV }}
- name: Configure AWS credentials (Prod) # AWS ์ธํ
(PROD)
if: contains(github.ref, 'main')
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload to S3 (Dev) # S3์ ํ์ผ ์
๋ก๋ (DEV)
if: contains(github.ref, 'develop')
run: aws s3 cp --region ${{ secrets.S3_REGION_DEV }} ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME_DEV }}/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Upload to S3 (Prod) # S3์ ํ์ผ ์
๋ก๋ (PROD)
if: contains(github.ref, 'main')
run: aws s3 cp --region ${{ secrets.S3_REGION }} ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME }}/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy (Dev) # CodeDeploy ๋ฐฐํฌ (DEV)
if: contains(github.ref, 'develop')
run: |
aws deploy create-deployment \
--application-name duaily-dev-deploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.DEPLOY_GROUP_DEV }} \
--s3-location bucket=${{ secrets.S3_BUCKET_NAME_DEV }},bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy (Prod) # CodeDeploy ๋ฐฐํฌ (PROD)
if: contains(github.ref, 'main')
run: |
aws deploy create-deployment \
--application-name duaily-deploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.DEPLOY_GROUP }} \
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip