Skip to content

Merge pull request #55 from CatsMeow492/enhancements/styling #40

Merge pull request #55 from CatsMeow492/enhancements/styling

Merge pull request #55 from CatsMeow492/enhancements/styling #40

name: Deploy Frontend to S3
on:
push:
branches:
- master
paths:
- 'frontend/**' # Only run when there are changes in the frontend directory
workflow_dispatch: # Allow manual trigger
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Set environment variables
run: |
echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" >> $GITHUB_ENV
echo "REACT_APP_GOOGLE_CLIENT_ID=${{ secrets.REACT_APP_GOOGLE_CLIENT_ID }}" >> $GITHUB_ENV
echo "REACT_APP_GOOGLE_CLIENT_SECRET=${{ secrets.REACT_APP_GOOGLE_CLIENT_SECRET }}" >> $GITHUB_ENV
- name: Install dependencies
run: |
cd frontend
npm install
- name: Build project
run: |
cd frontend
npm run build
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'frontend/build'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'us-east-1'
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"