Feat/add demo account (#78) #5
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 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 "/*" |