generated from pagopa/template-aws-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdeploy-fe-control-panel-ci.yaml
More file actions
96 lines (86 loc) · 3.5 KB
/
deploy-fe-control-panel-ci.yaml
File metadata and controls
96 lines (86 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Deploy FE Control Panel
on:
push:
branches:
- "main"
paths:
- "**/src/oneid/oneid-control-panel/**/CHANGELOG.md"
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 ${EVENT_NAME}"
if [ "${EVENT_NAME}" == "workflow_dispatch" ]; then
if [ "${INPUTS_ENVIRONMENT}" == "prod" ]; then
matrixStringifiedObject="{\"include\":[{\"environment\":\"prod\", \"region\":\"eu-south-1\"}, {\"environment\":\"prod\", \"region\":\"eu-central-1\"}]}"
else
matrixStringifiedObject="{\"include\":[{\"environment\":\"${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
env:
GITHUB_REF: ${{ github.ref }}
EVENT_NAME: ${{ github.event_name }}
INPUTS_ENVIRONMENT: ${{ github.event.inputs.environment }}
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 # v4.1.6 https://github.com/actions/checkout/releases/tag/v4.1.6
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/releases/tag/v4.0.2
with:
node-version: 20.x
- name: Run yarn install, lint and test
working-directory: src/oneid/oneid-control-panel
run: |
yarn install --frozen-lockfile
yarn lint
yarn test:coverage
if [ "$EVENT_NAME" == "workflow_dispatch" ]; then
yarn build --mode $INPUTS_ENVIRONMENT
else
yarn build --mode $MATRIX_ENVIRONMENT
fi
env:
EVENT_NAME: ${{ github.event_name }}
INPUTS_ENVIRONMENT: ${{ github.event.inputs.environment }}
MATRIX_ENVIRONMENT: ${{ matrix.environment }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.0.2
with:
role-to-assume: ${{ vars.IAM_ROLE_DEPLOY_FE }}
aws-region: ${{ matrix.region }}
- name: Copy to S3
run: |
aws s3 sync dist s3://${ASSETS_CONTROL_PANEL_BUCKET_NAME}
env:
ASSETS_CONTROL_PANEL_BUCKET_NAME: ${{ vars.ASSETS_CONTROL_PANEL_BUCKET_NAME }}
working-directory: src/oneid/oneid-control-panel