-
Notifications
You must be signed in to change notification settings - Fork 2
246 lines (236 loc) · 10 KB
/
deploy.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Deploy
on:
push:
branches:
- "*"
- "dependabot/**"
- "!skipci*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write
contents: read
actions: read
jobs:
unit-tests:
name: Unit Tests
uses: ./.github/workflows/unittest-workflow.yml
if: github.ref == 'refs/heads/master'
secrets:
CODE_CLIMATE_ID: ${{ secrets.CODE_CLIMATE_ID }}
deploy:
runs-on: ubuntu-latest
env:
SLS_DEPRECATION_DISABLE: "*" # Turn off deprecation warnings in the pipeline
steps:
- name: set branch_name # Some integrations (Dependabot & Snyk) build very long branch names. This is a switch to make long branch names shorter.
run: |
echo "GITHUB_REF=${GITHUB_REF}"
if [[ "$GITHUB_REF" =~ ^refs/heads/dependabot/.* ]]; then
echo "branch_name=`echo ${GITHUB_REF##*/*-} | md5sum | head -c 10 | sed 's/^/x/'`" >> $GITHUB_ENV
elif [[ "$GITHUB_REF" =~ ^refs/.*/snyk-* ]]; then
echo "branch_name=`echo ${GITHUB_REF##*/*-} | head -c 10 | sed 's/^/s/'`" >> $GITHUB_ENV
else
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- name: Validate branch name
run: ./.github/branchNameValidation.sh $STAGE_PREFIX$branch_name
- name: set branch specific variable names
run: ./.github/build_vars.sh set_names
- name: set variable values
run: ./.github/build_vars.sh set_values
env:
AWS_DEFAULT_REGION: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
STAGE_PREFIX: ${{ secrets.STAGE_PREFIX }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
CODE_CLIMATE_ID: ${{ secrets.CODE_CLIMATE_ID }}
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock', 'plugins/**') }}
- name: set path
run: |
echo "PATH=$(pwd)/node_modules/.bin/:$PATH" >> $GITHUB_ENV
- name: deploy
run: |
# When deploying multiple copies of this quickstart to the same AWS Account (not ideal), a prefix helps prevent stepping on each other.
# This can optionally be set as an GitHub Actions Secret
./deploy.sh $STAGE_PREFIX$branch_name
- name: Endpoint
id: endpoint
run: |
APPLICATION_ENDPOINT=$(./output.sh ui ApplicationEndpointUrl $STAGE_PREFIX$branch_name)
echo "application_endpoint=$APPLICATION_ENDPOINT" >> $GITHUB_OUTPUT
echo "## Application Endpoint" >> $GITHUB_STEP_SUMMARY
echo "<$APPLICATION_ENDPOINT>" >> $GITHUB_STEP_SUMMARY
working-directory: services
outputs:
application_endpoint: ${{ steps.endpoint.outputs.application_endpoint}}
# run e2e tests after deploy completes
e2e-tests-init:
name: Initialize End To End Tests
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/val' && github.ref != 'refs/heads/prod' }}
needs:
- deploy
runs-on: ubuntu-latest
steps:
- name: Verify Endpoint
if: ${{ needs.deploy.outputs.application_endpoint == ''}}
run: |
echo "No endpoint set, Check if the deploy workflow was successful."
exit 1
- uses: actions/checkout@v3
- name: set branch_name
run: |
if [[ "$GITHUB_REF" =~ ^refs/heads/dependabot/.* ]]; then # Dependabot builds very long branch names. This is a switch to make it shorter.
echo "branch_name=`echo ${GITHUB_REF#refs/heads/} | md5sum | head -c 10 | sed 's/^/x/'`" >> $GITHUB_ENV
else
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- name: set branch specific variable names
run: ./.github/build_vars.sh set_names
- name: set variable values
run: ./.github/build_vars.sh set_values
env:
AWS_DEFAULT_REGION: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
INFRASTRUCTURE_TYPE: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_INFRASTRUCTURE_TYPE] || secrets.INFRASTRUCTURE_TYPE || 'development' }}
STAGE_PREFIX: ${{ secrets.STAGE_PREFIX }}
COGNITO_TEST_USERS_PASSWORD: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_COGNITO_TEST_USERS_PASSWORD] || secrets.COGNITO_TEST_USERS_PASSWORD }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Combine yarn.lock files to single file
run: find services -maxdepth 3 -name yarn.lock | xargs cat yarn.lock > combined-yarn.txt
- name: cache service dependencies
uses: actions/cache@v3
with:
path: |
services/app-api/node_modules
services/uploads/node_modules
services/stream-functions/node_modules
services/ui/node_modules
services/ui-auth/node_modules
services/ui-src/node_modules
node_modules
key: ${{ runner.os }}-${{ hashFiles('combined-yarn.txt') }}
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: set path
run: |
echo "PATH=$(pwd)/node_modules/.bin/:$PATH" >> $GITHUB_ENV
outputs:
application_endpoint: ${{ needs.deploy.outputs.application_endpoint }}
setup-tests:
name: "Setup End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs: e2e-tests-init
with:
test-path: "init"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
child-e2e-measure-tests:
name: "Child End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
with:
test-path: "measures/child"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
adult-e2e-measure-tests:
name: "Adult End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
with:
test-path: "measures/adult"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
health-home-e2e-measure-tests:
name: "Health Home End To End Measure Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
with:
test-path: "measures/healthhome"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
e2e-feature-tests:
name: End To End Feature Tests
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
with:
test-path: "features"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
a11y-tests:
name: Accessibility Tests
needs:
- e2e-tests-init
- e2e-feature-tests
- child-e2e-measure-tests
- adult-e2e-measure-tests
- health-home-e2e-measure-tests
uses: ./.github/workflows/cypress-workflow.yml
with:
test-path: "a11y"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}