🐛fix:main.yml변경 #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "/*" |