-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (102 loc) ยท 4.04 KB
/
gradle-front.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
114
115
116
117
118
119
120
121
name: Frontend Workflows
on:
push:
branches:
- main # main์ผ๋ก pushํ๋ฉด workflow ์คํ
paths:
- 'SCM/frontend/**'
pull_request:
types: [ opened, reopened, synchronize ] # Pull Request๊ฐ ์ด๋ฆฌ๊ฑฐ๋, ๋ค์ ์ด๋ฆฌ๊ฑฐ๋, ๋๊ธฐํ๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค.
branches:
- main # main์ผ๋ก prํ๋ฉด workflow ์คํ
jobs:
CI:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest # ์ต์ Ubuntu ํ๊ฒฝ
permissions:
contents: read # contents read ๊ถํ์ ๋ถ์ฌ
steps:
- uses: actions/checkout@v4 # ๋ ํฌ์งํ ๋ฆฌ ์ฝ๋๋ฅผ ์ฒดํฌ์์ [v4๋ผ๊ณ ๋ฒ์ ์ง์ ์ v4๋ก ์์ํ๋ ์ต์ ๋ฆด๋ฆฌ์ฆ ๋ฒ์ ์ ์ฌ์ฉ (์ ํํ ๋ฒ์ ๊ธฐ์
์ ํด๋น ๋ฆด๋ฆฌ์ฆ ๋ฒ์ ๋ง ์ฌ์ฉ)]
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Create .env.template
run: |
mkdir -p SCM/frontend
cat > SCM/frontend/.env.template <<EOL
VITE_API_URL=\${BACKEND_URL}
EOF
- name: Set env
run: |
envsubst < SCM/frontend/.env.template > SCM/frontend/.env
echo "Generated .env:"
cat SCM/frontend/.env
env:
BACKEND_URL: ${{ secrets.BACKEND_URL }}
- name: Install dependencies
run: npm install
working-directory: ./SCM/frontend
- name: Build project
run: npm run build
working-directory: ./SCM/frontend
- name: Deploy to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws s3 sync ./SCM/frontend/dist s3://${{ secrets.S3_BUCKET_NAME }} --delete
- name: Invalidate CloudFront Cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
run: |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
CD:
if: github.event_name == 'push'
runs-on: ubuntu-latest # ์ต์ Ubuntu ํ๊ฒฝ
permissions:
contents: read # contents read ๊ถํ์ ๋ถ์ฌ
steps:
- uses: actions/checkout@v4 # ๋ ํฌ์งํ ๋ฆฌ ์ฝ๋๋ฅผ ์ฒดํฌ์์ [v4๋ผ๊ณ ๋ฒ์ ์ง์ ์ v4๋ก ์์ํ๋ ์ต์ ๋ฆด๋ฆฌ์ฆ ๋ฒ์ ์ ์ฌ์ฉ (์ ํํ ๋ฒ์ ๊ธฐ์
์ ํด๋น ๋ฆด๋ฆฌ์ฆ ๋ฒ์ ๋ง ์ฌ์ฉ)]
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Create .env.template
run: |
mkdir -p SCM/frontend
cat > SCM/frontend/.env.template <<EOL
VITE_API_URL=\${BACKEND_URL}
EOF
- name: Set env
run: |
envsubst < SCM/frontend/.env.template > SCM/frontend/.env
echo "Generated .env:"
cat SCM/frontend/.env
env:
BACKEND_URL: ${{ secrets.BACKEND_URL }}
- name: Install dependencies
run: npm install
working-directory: ./SCM/frontend
- name: Build project
run: npm run build
working-directory: ./SCM/frontend
- name: Deploy to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws s3 sync ./SCM/frontend/dist s3://${{ secrets.S3_BUCKET_NAME }} --delete
- name: Invalidate CloudFront Cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
run: |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"