Skip to content

Commit 2b18852

Browse files
authored
feat: add deployment pipeline for control panel's fe (#744)
2 parents deec987 + df2ff54 commit 2b18852

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy FE Control Panel
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- "**/src/oneid/oneid-control-panel**"
9+
workflow_dispatch:
10+
inputs:
11+
environment:
12+
description: 'Choose environment'
13+
type: choice
14+
required: true
15+
default: dev
16+
options:
17+
- dev
18+
- uat
19+
- prod
20+
21+
jobs:
22+
setup:
23+
runs-on: ubuntu-22.04
24+
outputs:
25+
matrix: ${{ steps.setmatrix.outputs.matrix }}
26+
27+
steps:
28+
- name: Set Dynamic Env Matrix
29+
id: setmatrix
30+
run: |
31+
echo "github.ref ${{ github.ref }}"
32+
echo "event name ${{ github.event_name }}"
33+
34+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
35+
if [ "${{ github.event.inputs.environment }}" == "prod" ]; then
36+
matrixStringifiedObject="{\"include\":[{\"environment\":\"prod\", \"region\":\"eu-south-1\"}, {\"environment\":\"prod\", \"region\":\"eu-central-1\"}]}"
37+
else
38+
matrixStringifiedObject="{\"include\":[{\"environment\":\"${{ github.event.inputs.environment }}\", \"region\":\"eu-south-1\"}]}"
39+
fi
40+
else
41+
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\"}]}"
42+
fi
43+
44+
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
45+
46+
deploy:
47+
runs-on: ubuntu-22.04
48+
if: ${{ needs.setup.outputs.matrix != '' }}
49+
needs: setup
50+
permissions:
51+
id-token: write
52+
contents: read
53+
strategy:
54+
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
55+
56+
continue-on-error: false
57+
environment: ${{ matrix.environment == 'prod' && format('{0}/{1}', matrix.environment, matrix.region) || matrix.environment }}
58+
59+
steps:
60+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
61+
- name: Use Node.js 20.x
62+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
63+
with:
64+
node-version: 20.x
65+
- name: Run yarn install, lint and test
66+
working-directory: src/oneid/oneid-control-panel
67+
run: |
68+
yarn install --frozen-lockfile
69+
yarn lint
70+
yarn test:coverage
71+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
72+
yarn build --mode ${{ github.event.inputs.environment }}
73+
else
74+
yarn build --mode ${{ matrix.environment }}
75+
fi
76+
77+
- name: Configure AWS Credentials
78+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
79+
with:
80+
role-to-assume: ${{ vars.IAM_ROLE_DEPLOY_FE }}
81+
aws-region: ${{ matrix.region }}
82+
83+
- name: Copy to S3
84+
run: |
85+
aws s3 sync dist s3://${{ vars.ASSETS_CONTROL_PANEL_BUCKET_NAME }}
86+
working-directory: src/oneid/oneid-control-panel

0 commit comments

Comments
 (0)