Skip to content

Merge pull request #2 from wafflestudio/develop #12

Merge pull request #2 from wafflestudio/develop

Merge pull request #2 from wafflestudio/develop #12

Workflow file for this run

name: Deploy to S3 and CloudFront
on:
push:
branches:
- main
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1. Check out the repository
- name: Checkout Code
uses: actions/checkout@v3
# 2. Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 23 # Update this if your app uses a different version
# 3. Install dependencies
- name: Install Dependencies
run: yarn install
# 4. Build the app
- name: Build React App
run: yarn build
# 5. Deploy to Production S3 Bucket (main branch)
- name: Deploy to Production
if: github.ref == 'refs/heads/main'
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_PROD_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist
# 6. Deploy to Development S3 Bucket (develop branch)
- name: Deploy to Development
if: github.ref == 'refs/heads/develop'
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_DEV_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist
# 7. Invalidate CloudFront Cache (Production)
- name: Invalidate CloudFront Cache (Production)
if: github.ref == 'refs/heads/main'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_PROD_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'
# 8. Invalidate CloudFront Cache (Development)
- name: Invalidate CloudFront Cache (Development)
if: github.ref == 'refs/heads/develop'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_DEV_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'