generated from pagopa/template-aws-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (81 loc) · 2.88 KB
/
deploy-fe-ci.yaml
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
name: Deploy FE
on:
push:
branches:
- "main"
- "dev"
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
jobs:
setup:
runs-on: ubuntu-22.04
steps:
- name: Set Dynamic Env Matrix
id: setmatrix
run: |
echo "github.ref ${{ github.ref }}"
echo "event name ${{ github.event_name }}"
if [ ${{ github.ref == 'refs/heads/main' }} == true ] && [ ${{ github.event_name != 'workflow_dispatch' }} == true ]; then
matrixStringifiedObject="{\"include\":[{\"environment\":\"uat\"},{\"environment\":\"prod\"}]}"
elif [ ${{ github.event_name == 'workflow_dispatch' }} == true ] ; then
matrixStringifiedObject="{\"include\":[{\"environment\":\"${{ github.event.inputs.environment}}\" }]}"
else
matrixStringifiedObject="{\"include\":[{\"environment\":\"dev\", \"env_short\": \"d\"}]}"
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
yarn build
- name: Archive build artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: assets
path: src/oneid/oneid-ecs-core/src/main/webui/build
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 }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
with:
name: assets
path: src/oneid/oneid-ecs-core/src/main/webui/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
role-to-assume: ${{ vars.IAM_ROLE_DEPLOY_FE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Copy to S3
run: |
aws s3 sync build s3://${{ vars.ASSETS_BUCKET_NAME }}
working-directory: src/oneid/oneid-ecs-core/src/main/webui