Update build-and-deploy.yaml #10
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: Deploy to CloudFront | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 # workflow에서 액세스할 수 있도록 저장소를 체크아웃 | |
- name: Cache node modules | |
id: node-cache | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules- | |
- name: Install dependencies | |
run: yarn install | |
- name: Build | |
run: CI='false' yarn build | |
- name: S3 Deploy | |
run: aws s3 sync ./build s3://bookpharmacy.store/ --acl bucket-owner-full-control # 현재 build된 폴더에 접근 후 s3 버킷인 csr-test-1-bucket에 파일 업로드 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
- name: Invalidate CloudFront Cache # 새로 리소스를 업데이트할 때 기존 캐시 무효화 | |
uses: chetan/invalidate-cloudfront-action@master | |
env: | |
AWS_DISTRIBUTION: ${{ secrets.AWS_DISTRIBUTION_ID }} | |
PATHS: '/index.html' | |
continue-on-error: true |