-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.86 KB
/
main.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
name: React build
on:
pull_request:
types: [closed] # PR이 병합(closed)될 때 실행
branches:
- master # 대상 브랜치가 master일 때 실행
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code. # 레포지토리 체크아웃
uses: actions/checkout@master
- name: Cache node modules # node modules 캐싱
uses: actions/cache@v1
with:
path: node_modules # 프로젝트의 node_modules가 있는 경로로 설정
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install Dependencies # 의존 파일 설치
run: npm install # npm install을 실행할 경로로 설정
- name: Create .env file # .env 파일 생성
run: |
echo "VITE_SERVER_URL=${{ secrets.VITE_SERVER_URL }}" >> .env
echo "VITE_KAKAOMAP_KEY=${{ secrets.VITE_KAKAOMAP_KEY }}" >> .env
echo "VITE_PUBLIC_URL=${{ secrets.VITE_PUBLIC_URL }}" >> .env
- name: Build # React Build
run: npm run build # npm run build를 실행할 경로로 설정
- name: Deploy # S3에 배포하기
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 cp \
--recursive \
--region us-east-1 \
dist s3://yeungnam-nyang.site
- name: CloudFront invalidation # CloudFront 캐시 무효화
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.AWS_DISTRIBUTION_ID }} \
--paths "/*"