Skip to content

Deploy FE

Deploy FE #56

Workflow file for this run

name: Deploy FE
on:
push:
branches:
- "main"
paths:
- "**/src/oneid/oneid-fe**"
workflow_dispatch:
inputs:
environment:
description: 'Choose environment'
type: choice
required: true
default: dev
options:
- dev
- uat
- prod
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
steps:
- name: Set Dynamic Env Matrix
id: setmatrix
run: |
echo "github.ref ${{ github.ref }}"
echo "event name ${{ github.event_name }}"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.environment }}" == "prod" ]; then
matrixStringifiedObject="{\"include\":[{\"environment\":\"prod\", \"region\":\"eu-south-1\"}, {\"environment\":\"prod\", \"region\":\"eu-central-1\"}]}"
else
matrixStringifiedObject="{\"include\":[{\"environment\":\"${{ github.event.inputs.environment }}\", \"region\":\"eu-south-1\"}]}"
fi
else
matrixStringifiedObject="{\"include\":[{\"environment\":\"dev\", \"region\":\"eu-south-1\"}, {\"environment\":\"uat\", \"region\":\"eu-south-1\"}, {\"environment\":\"prod\", \"region\":\"eu-south-1\"}, {\"environment\":\"prod\", \"region\":\"eu-central-1\"}]}"
fi
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-22.04
if: ${{ needs.setup.outputs.matrix != '' }}
needs: setup
permissions:
id-token: write
contents: read
strategy:
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
continue-on-error: false
environment: ${{ matrix.environment == 'prod' && format('{0}/{1}', matrix.environment, matrix.region) || matrix.environment }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: 20.x
- name: Run yarn install, lint and test
working-directory: src/oneid/oneid-fe
run: |
yarn install --frozen-lockfile
yarn lint
yarn test:coverage
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
yarn build --mode ${{ github.event.inputs.environment }}
else
yarn build --mode ${{ matrix.environment }}
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
role-to-assume: ${{ vars.IAM_ROLE_DEPLOY_FE }}
aws-region: ${{ matrix.region }}
- name: Copy to S3
run: |
aws s3 sync dist s3://${{ vars.ASSETS_BUCKET_NAME }}
working-directory: src/oneid/oneid-fe