Skip to content

Feat/add demo account (#78) #5

Feat/add demo account (#78)

Feat/add demo account (#78) #5

Workflow file for this run

name: Deploy React App to S3
on:
push:
branches:
- main
paths:
- 'src/**' # Only trigger when files in src directory change
- 'package.json' # Only trigger when package.json changes
- 'package-lock.json' # Only trigger when package-lock.json changes
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ secrets.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Build React app
run: |
cp .env.example .env
npm run build
env:
CI: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy to S3
run: |
# Empty the S3 bucket
aws s3 rm s3://${{ secrets.S3_BUCKET }} --recursive
# Upload new build files
aws s3 sync build/ s3://${{ secrets.S3_BUCKET }} --delete
- name: Invalidate CloudFront
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"