-
Notifications
You must be signed in to change notification settings - Fork 58
343 lines (308 loc) · 14.5 KB
/
prautorun.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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Pull Request Deploy Auto Run
on:
pull_request:
workflow_dispatch:
inputs:
pr-number:
description: "Pull Request Number:"
type: string
required: true
namespace:
description: "Deploy To:"
type: choice
required: true
options:
- The Q Dev
- QMS Dev
- The Q Test
jobs:
##### SETUP ##################################################################
parse-inputs:
name: refs/pull/${{ github.event.pull_request.number }}/head to echo ${{ github.event.inputs.namespace }}
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.parse.outputs.environment }}
image-tag: ${{ steps.parse.outputs.image-tag }}
push-qms: ${{ steps.parse.outputs.push-qms }}
push-theq: ${{ steps.parse.outputs.push-theq }}
ref: ${{ steps.parse.outputs.ref }}
steps:
# Use the input values to create more coding-friendly values.
- name: Parse Inputs
id: parse
run: |
ENVIRONMENT="dev"
echo ENVIRONMENT:$ENVIRONMENT
echo "environment=$ENVIRONMENT" >> $GITHUB_OUTPUT
IMAGE_TAG=pr${{ github.event.pull_request.number }}
echo IMAGE_TAG:$IMAGE_TAG
echo "image-tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
if [ $GITHUB_REPOSITORY_OWNER != "bcgov" ]; then
# Never push in forks - useful and safer for development.
PUSH_QMS=false
PUSH_THEQ=false
elif [[ "${{ github.event.inputs.namespace }}" == QMS* ]]; then
PUSH_QMS=true
PUSH_THEQ=false
else
PUSH_QMS=false
PUSH_THEQ=true
fi
echo PUSH_QMS:$PUSH_QMS
echo "push-qms=$PUSH_QMS" >> $GITHUB_OUTPUT
echo PUSH_THEQ:$PUSH_THEQ
echo "push-theq=$PUSH_THEQ" >> $GITHUB_OUTPUT
REF=refs/pull/${{ github.event.pull_request.number }}/head
echo REF:$REF
echo "ref=$REF" >> $GITHUB_OUTPUT
##### TEST ###################################################################
appointment-frontend-cypress:
name: Appointment Frontend Cypress
needs: parse-inputs
uses: ./.github/workflows/tyu-reusable-appointment-frontend-cypress.yaml
secrets:
bceid-endpoint: ${{ secrets.CYPRESS_BCEID_ENDPOINT }}
bceid-password: ${{ secrets.CYPRESS_BCEID_PASSWORD }}
bceid-username: ${{ secrets.CYPRESS_BCEID_USERNAME }}
cypress-project-id: ${{ secrets.CYPRESS_PROJECT_ID }}
cypress-record-key: ${{ secrets.CYPRESS_RECORD_KEY }}
keycloak-auth-url: ${{ secrets.KEYCLOAK_AUTH_URL_DEV }}/auth/
keycloak-client: ${{ secrets.KEYCLOAK_APPOINTMENTS_FRONTEND_CLIENT }}
keycloak-realm: ${{ secrets.KEYCLOAK_REALM }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
##### BUILD ##################################################################
appointment-frontend:
name: appointment-frontend
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-dockerfile.yaml
secrets:
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
artifactory-registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: appointment-frontend
image-name: appointment-nginx-frontend
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
feedback-api:
name: feedback-api
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-s2i.yaml
secrets:
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: feedback-api
image-name: feedback-api
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
notifications-api:
name: notifications-api
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-s2i.yaml
secrets:
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: notifications-api
image-name: notifications-api
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
queue-management-api:
name: queue-management-api
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-s2i.yaml
secrets:
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
artifactory-registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: api
image-name: queue-management-api
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
queue-management-frontend:
name: queue-management-frontend
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-dockerfile.yaml
secrets:
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
artifactory-registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: frontend
image-name: queue-management-nginx-frontend
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
send-appointment-reminder-crond:
name: send-appointment-reminder-crond
needs: [parse-inputs, appointment-frontend-cypress]
uses: ./.github/workflows/reusable-build-dockerfile.yaml
secrets:
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
artifactory-registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
namespace-theq: ${{ secrets.LICENCE_PLATE_THEQ }}-tools
namespace-theq-password: ${{ secrets.SA_PASSWORD_THEQ_TOOLS }}
namespace-theq-username: ${{ secrets.SA_USERNAME }}
namespace-qms: ${{ secrets.LICENCE_PLATE_QMS }}-tools
namespace-qms-password: ${{ secrets.SA_PASSWORD_QMS_TOOLS }}
namespace-qms-username: ${{ secrets.SA_USERNAME }}
openshift-registry: ${{ secrets.OPENSHIFT_REGISTRY }}
with:
ref: ${{ needs.parse-inputs.outputs.ref }}
directory: jobs/appointment_reminder
image-name: send-appointment-reminder-crond
image-tags: ${{ needs.parse-inputs.outputs.image-tag }}
push-qms: ${{ needs.parse-inputs.outputs.push-qms == 'true' }}
push-theq: ${{ needs.parse-inputs.outputs.push-theq == 'true' }}
##### DEPLOY #################################################################
tag:
name: Tag
if: github.repository_owner == 'bcgov'
needs: [parse-inputs, appointment-frontend, feedback-api, notifications-api, queue-management-api, queue-management-frontend, send-appointment-reminder-crond]
uses: ./.github/workflows/reusable-tag-image.yaml
secrets:
licence-plate: ${{ needs.parse-inputs.outputs.push-qms == 'true' && secrets.LICENCE_PLATE_QMS || secrets.LICENCE_PLATE_THEQ }}
openshift-api: ${{ secrets.OPENSHIFT_API }}
token: ${{ needs.parse-inputs.outputs.push-qms == 'true' && secrets.SA_PASSWORD_QMS_TOOLS || secrets.SA_PASSWORD_THEQ_TOOLS }}
with:
image-names: appointment-nginx-frontend feedback-api notifications-api queue-management-api queue-management-nginx-frontend send-appointment-reminder-crond
tag-from: ${{ needs.parse-inputs.outputs.image-tag }}
tag-to: ${{ needs.parse-inputs.outputs.environment }}
wait-for-rollouts:
name: Wait for Rollouts
if: github.repository_owner == 'bcgov'
needs: [parse-inputs, tag]
uses: ./.github/workflows/reusable-wait-for-rollouts.yaml
secrets:
licence-plate: ${{ needs.parse-inputs.outputs.push-qms == 'true' && secrets.LICENCE_PLATE_QMS || secrets.LICENCE_PLATE_THEQ }}
openshift-api: ${{ secrets.OPENSHIFT_API }}
token: ${{ needs.parse-inputs.outputs.push-qms == 'true' && secrets.SA_PASSWORD_QMS_DEV || ( needs.parse-inputs.outputs.environment == 'dev' && secrets.SA_PASSWORD_THEQ_DEV || secrets.SA_PASSWORD_THEQ_TEST ) }}
with:
image-names: appointment-nginx-frontend feedback-api notifications-api queue-management-api queue-management-nginx-frontend send-appointment-reminder-crond-${{ needs.parse-inputs.outputs.environment }}
tag-to: ${{ needs.parse-inputs.outputs.environment }}
##### TEST ###################################################################
# Only run Newman for The Q dev - other environments will fail due to data.
newman-theq-dev:
name: Newman Tests
if: github.event.inputs.namespace != 'The Q Dev'
needs: [parse-inputs, wait-for-rollouts]
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: NPM Install
run: |
cd api/postman
npm install newman
- name: Run Newman Tests
run: |
cd api/postman
node_modules/newman/bin/newman.js run API_Test_TheQ_Booking.json \
-e postman_env.json \
--delay-request 250 \
--global-var 'auth_url=${{ vars.POSTMAN_AUTH_URL_DEV }}' \
--global-var 'client_secret=${{ secrets.POSTMAN_CLIENT_SECRET_DEV }}' \
--global-var 'clientid=${{ vars.POSTMAN_CLIENTID_DEV }}' \
--global-var 'password=${{ secrets.POSTMAN_PASSWORD }}' \
--global-var 'password_nonqtxn=${{ secrets.POSTMAN_PASSWORD_NONQTXN }}' \
--global-var 'public_url=${{ vars.POSTMAN_PUBLIC_API_URL_THEQ_DEV }}' \
--global-var 'public_user_id=${{ vars.POSTMAN_PUBLIC_USERID }}' \
--global-var 'public_user_password=${{ secrets.POSTMAN_PASSWORD_PUBLIC_USER }}' \
--global-var 'realm=${{ vars.POSTMAN_REALM }}' \
--global-var 'url=${{ vars.POSTMAN_API_URL_THEQ_DEV }}' \
--global-var 'userid=${{ vars.POSTMAN_USERID }}' \
--global-var 'userid_nonqtxn=${{ vars.POSTMAN_USERID_NONQTXN }}'
owasp-staff:
name: OWASP ZAP Scan of Staff Frontend
needs: [parse-inputs, wait-for-rollouts]
runs-on: ubuntu-latest
steps:
- name: Get Parameters
run: |
if [ ${{ needs.parse-inputs.outputs.push-qms }} == true ]; then
echo "ZAP_URL=${{ secrets.ZAP_STAFFURL_QMS_DEV }}" >> $GITHUB_ENV
elif [ ${{ needs.parse-inputs.outputs.environment }} == dev ]; then
echo "ZAP_URL=${{ secrets.ZAP_STAFFURL_THEQ_DEV }}" >> $GITHUB_ENV
else
echo "ZAP_URL=${{ secrets.ZAP_STAFFURL_THEQ_TEST }}" >> $GITHUB_ENV
fi
- name: OWASP ZAP Scan
uses: zaproxy/[email protected]
with:
allow_issue_writing: false
cmd_options: '-z "-config scanner.threadPerHost=20"'
target: ${{ env.ZAP_URL }}
- name: Upload Report as Artifact
uses: actions/upload-artifact@v3
with:
name: OWASP ZAP - Staff Front End Report
path: report_html.html
owasp-appointment:
name: OWASP ZAP Scan of Appointment Frontend
needs: [parse-inputs, wait-for-rollouts]
runs-on: ubuntu-latest
steps:
- name: Get Parameters
run: |
if [ ${{ needs.parse-inputs.outputs.push-qms }} == true ]; then
echo "ZAP_URL=${{ secrets.ZAP_APPTMNTURL_QMS_DEV }}" >> $GITHUB_ENV
elif [ ${{ needs.parse-inputs.outputs.environment }} == dev ]; then
echo "ZAP_URL=${{ secrets.ZAP_APPTMNTURL_THEQ_DEV }}" >> $GITHUB_ENV
else
echo "ZAP_URL=${{ secrets.ZAP_APPTMNTURL_THEQ_TEST }}" >> $GITHUB_ENV
fi
- name: OWASP ZAP Scan
uses: zaproxy/[email protected]
with:
allow_issue_writing: false
cmd_options: '-z "-config scanner.threadPerHost=20"'
target: ${{ env.ZAP_URL }}
- name: Upload Report as Artifact
uses: actions/upload-artifact@v3
with:
name: OWASP ZAP - Appointment Front End Report
path: report_html.html