Skip to content

cd: Add workflow for deploying react frontend to S3 #1

cd: Add workflow for deploying react frontend to S3

cd: Add workflow for deploying react frontend to S3 #1

name: CD deploy to S3
on:
push:
branches:
- 'release/v[0-9]+.[0-9]+'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.11.1'
- name: Install dependencies
working-directory: ./react_frontend
run: npm install
- name: Set environment variables
run: echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" >> $GITHUB_ENV
- name: Build React app
working-directory: ./react_frontend
run: npm run build
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --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 }}
AWS_REGION: 'ap-southeast-1'
SOURCE_DIR: './react_frontend/build'