Skip to content

Merge pull request #162 from wafflestudio/158-bug-story #31

Merge pull request #162 from wafflestudio/158-bug-story

Merge pull request #162 from wafflestudio/158-bug-story #31

Workflow file for this run

name: CD (Deploy to S3 + CloudFront)
on:
push:
branches:
- main
- dev
jobs:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build project
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
run: yarn build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload to S3
run: |
aws s3 sync dist s3://${{ secrets.S3_BUCKET_NAME }} \
--delete \
--cache-control "public,max-age=31536000,immutable" \
--exclude "index.html"
- name: Upload index.html with no-cache
run: |
aws s3 cp dist/index.html s3://${{ secrets.S3_BUCKET_NAME }}/index.html \
--cache-control "no-cache,no-store,must-revalidate"
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"