Build + Deploy Frontend #30
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: Build + Deploy Frontend | |
on: | |
workflow_dispatch: | |
inputs: | |
buildPath: | |
description: 'Frontend App' | |
required: true | |
default: 'game' | |
type: choice | |
options: | |
- game | |
- xmas | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: './frontend/${{ inputs.buildPath }}' | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: 'frontend/${{ inputs.buildPath }}/yarn.lock' | |
- name: Install Dependancies | |
run: yarn install | |
# - name: Test Dashboard | |
# run: yarn test | |
- name: Build Client | |
run: yarn build | |
- name: Configure AWS Credentials for S3 Access | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_BUCKET_ROLE_ARN }} | |
role-duration-seconds: 900 | |
aws-region: eu-west-2 | |
- name: Deploy static site to S3 bucket | |
run: | | |
aws s3 sync ./dist/ "${{ secrets.AWS_BUCKET_PATH }}/${{ inputs.buildPath }}/" --delete | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DISTRIBUTION_ID }} --paths "/projects/${{ inputs.buildPath }}/index.html" |