Skip to content

Deploy Production to s3/Cloudfront #7

Deploy Production to s3/Cloudfront

Deploy Production to s3/Cloudfront #7

Workflow file for this run

name: Deploy Production to s3/Cloudfront
on:
workflow_dispatch:
release:
types: [published]
env:
AWS_REGION: us-west-2
jobs:
build_fe:
name: Build and Test
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '21.6.2'
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: install dependencies and build
run: |
npm install
npm run build
- name: Move Build to tmp
run: |
mkdir -p /tmp/workspace/build
mv -v out/* /tmp/workspace/build
- name: Temporarily save Build to artifacts
uses: actions/upload-artifact@v2
with:
name: build-client
path: /tmp/workspace
deploy_fe:
needs: build_fe
runs-on: ubuntu-latest
environment: production
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Retrieve saved Build
uses: actions/download-artifact@v2
with:
name: build-client
path: /tmp/workspace
- name: Deploy to S3
run: aws s3 sync /tmp/workspace/build/ s3://pv-validation-hub-website --acl public-read
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.FE_CF_ID }} --paths '/*'