Deploy FE #42
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: Deploy FE | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "**/src/oneid/oneid-ecs-core/src/main/webui**" | |
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 | |
build: | |
runs-on: ubuntu-22.04 | |
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-ecs-core/src/main/webui | |
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 dev | |
fi | |
- name: Archive build artifacts | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 | |
with: | |
name: assets | |
path: src/oneid/oneid-ecs-core/src/main/webui/dist | |
deploy: | |
runs-on: ubuntu-22.04 | |
if: ${{ needs.setup.outputs.matrix != '' }} | |
needs: [setup, build] | |
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: | |
- name: Download build artifacts | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e | |
with: | |
name: assets | |
path: src/oneid/oneid-ecs-core/src/main/webui/dist | |
- 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-ecs-core/src/main/webui |