-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (56 loc) · 2.05 KB
/
front-build.yaml
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
name: PROMA-FRONT-CI/CD
on:
push:
branches:
- dev
pull_request:
types:
- closed
branches:
- dev
jobs:
build:
name: PROMA-FRONT-CI/CD
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'push'
steps:
- name: Github Action 설정
uses: actions/checkout@v3
- name: NPM 이용 cache 설정
id: npm-cache-dir
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: 라이브러리 설치 및 업데이트
run: npm install
- name: 환경 변수 설정
run: |
echo "REACT_APP_BACKEND_SERVER_URL=${{ secrets.REACT_APP_BACKEND_SERVER_URL }}" >> .env
echo "REACT_APP_AI_SERVER_URL=${{ secrets.REACT_APP_AI_SERVER_URL }}" >> .env
echo "REACT_APP_REGION=${{ secrets.REACT_APP_REGION }}" >> .env
echo "REACT_APP_ACCESS_KEY_ID=${{ secrets.REACT_APP_ACCESS_KEY_ID }}" >> .env
echo "REACT_APP_SECRET_ACCESS_KEY=${{ secrets.REACT_APP_SECRET_ACCESS_KEY }}" >> .env
echo "REACT_APP_BUCKET_NAME=${{ secrets.REACT_APP_BUCKET_NAME }}" >> .env
- name: react 빌드
run: npm run build
- name: AWS 인증
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY_ID }}
aws-region: ap-northeast-2
- name: S3 자동 배포
env:
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME}}
run: |
aws s3 sync \
./build s3://$BUCKET_NAME
- name: CloudFront 무효화 설정
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*"