-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.sds.release.yml
492 lines (452 loc) · 18.5 KB
/
azure-pipelines.sds.release.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
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
name: $(Date:yyyyMMddHHmm)-$(Rev:r)
trigger:
- release/*
pr: none
resources:
repositories:
- repository: azTemplates
type: github
name: hmcts/azure-devops-templates
ref: master
endpoint: hmcts
pool:
vmImage: ubuntu-22.04
#####################################################
# Pre-Release Tasks. ################################
stages:
- stage: Pre_Run_Tasks
displayName: Pre-Release Tasks
variables:
- template: variables/shared.yaml
jobs:
- job: Generate_Entity_Framework_Script
displayName: "Generate Entity Framework Script"
steps:
- template: templates/Database/EntityFramework/generate-script.yaml@azTemplates
parameters:
outputPath: $(Build.StagingDirectory)
contextName: ${{ variables.efContextName }}
workingPath: $(System.DefaultWorkingDirectory)/${{ variables.appName }}/${{ variables.appName }}
projectName: ${{ variables.efProjectName }}
migrationsPath: ${{ variables.appName }}/${{ variables.appName }}.DAL/Migrations
- job: PublishAcceptanceTests
displayName: Publish Acceptance Tests
variables:
projectPath: "${{ variables.appName }}/${{ variables.appName }}"
steps:
- template: templates\dotnet\publish-acceptance-tests.yml@azTemplates
parameters:
vstsFeedId: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
coreProjectPath: $(projectPath)
#####################################################
# Run Entity Framework ITHC. #####################
- stage: Run_Entity_Framework_ITHC
displayName: ITHC EF Release
dependsOn:
- Pre_Run_Tasks
variables:
- template: variables/ithc.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Run_Entity_Framework_ITHC
pool:
vmImage: 'windows-latest'
displayName: Run Entity Framework ITHC
steps:
- download: current
displayName: Download Sql Artifact
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: delete
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
- template: templates/Database/EntityFramework/run-entity-framework.yaml@azTemplates
parameters:
sqlServerResourceGroup: ${{ variables.vhResourceGroup }}
sqlServerName: ${{ variables.vhSQLServerName }}
databaseName: ${{ variables.videoApiDbName }}
azureSubscription: ${{ variables.subscriptionName }}
sqlScriptLocation: "$(Pipeline.Workspace)/${{ variables.efContextName }}-$(Build.BuildId)/${{ variables.efContextName }}.sql"
kvfirewallRequired: false
kvName: ${{ variables.vhKeyVault }}
kvSqlPasswordSecret: ${{ variables.vhSqlPasswordSecret }}
kvSqlUsernameSecret: ${{ variables.vhSqlUsernameSecret }}
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: add
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
lockType: CanNotDelete
#####################################################
# Run Entity Framework Staging. #####################
- stage: Run_Entity_Framework_Staging
displayName: Staging EF Release
dependsOn:
- Pre_Run_Tasks
variables:
- template: variables/staging.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Run_Entity_Framework_Staging
pool:
vmImage: 'windows-latest'
displayName: Run Entity Framework Staging
steps:
- download: current
displayName: Download Sql Artifact
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: delete
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
- template: templates/Database/EntityFramework/run-entity-framework.yaml@azTemplates
parameters:
sqlServerResourceGroup: ${{ variables.vhResourceGroup }}
sqlServerName: ${{ variables.vhSQLServerName }}
databaseName: ${{ variables.videoApiDbName }}
azureSubscription: ${{ variables.subscriptionName }}
sqlScriptLocation: "$(Pipeline.Workspace)/${{ variables.efContextName }}-$(Build.BuildId)/${{ variables.efContextName }}.sql"
kvfirewallRequired: false
kvName: ${{ variables.vhKeyVault }}
kvSqlPasswordSecret: ${{ variables.vhSqlPasswordSecret }}
kvSqlUsernameSecret: ${{ variables.vhSqlUsernameSecret }}
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: add
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
lockType: CanNotDelete
#####################################################
# Build Docker Image & Push. ########################
- stage: Docker_Build_Push
displayName: Docker Build & Push Image
dependsOn:
- Run_Entity_Framework_Staging
- Run_Entity_Framework_ITHC
variables:
- template: variables/staging.yaml
- template: variables/shared.yaml
jobs:
- job: Docker_Build
displayName: "Docker Build and Push"
steps:
- checkout: self
- bash: |
sed -i "s|</configuration>|<packageSourceCredentials><vh-packages><add key=\"Username\" value=\"PAT\" /><add key=\"ClearTextPassword\" value=\"$(System.AccessToken)\" /></vh-packages></packageSourceCredentials></configuration>|" nuget.config
displayName: Add NuGet Feed Authentication
workingDirectory: ${{ variables.appName }}
- template: templates\Containerisation\docker\docker-compose.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
- template: templates\Containerisation\docker\docker-push-azure.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
imageName: "${{ variables.imageName }}"
imageTags:
- '${{ variables.stagingTagName }}'
#########################################
# Push Helm Charts to Repo. #############
- stage: Helm_Staging
displayName: Push Helm Charts
dependsOn:
- Docker_Build_Push
variables:
- template: variables/staging.yaml
- template: variables/shared.yaml
- group: vh-github-app-credentials
jobs:
- job: Helm
displayName: "Helm Push"
steps:
- checkout: self
- template: templates\Github\get-app-token.yaml@azTemplates
parameters:
privateKeyFileName: ${{ variables.gh_app_private_key_file_name }}
appId: $(gh_app_app_id)
- template: templates\Github\push-to-helm-chart-repo.yaml@azTemplates
parameters:
chartName: ${{ variables.chartName }}
chartPath: ${{ variables.chartPath }}
githubToken: $(githubappinstall.token)
githubUsername: $(gh_app_name)
githubEmail: "$(gh_app_app_id)+$(gh_app_name)[bot]@users.noreply.github.com"
subDirectory: ${{ variables.subDirectory }}
##################################################
# Run Acceptance Tests. ##########################
- stage: Acceptance_Tests_Staging
dependsOn:
- Helm_Staging
displayName: Acceptance Tests Staging
variables:
- group: vh-video-api
- template: variables/staging.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
- name: dnsRecordName
value: vh-${{ variables.git_repo_name }}
jobs:
- job: AcceptanceTestsStaging
pool: VH Self Hosted
displayName: Acceptance Tests Staging
steps:
- template: templates/dotnet/run-acceptance-tests.yml@azTemplates
parameters:
environment: ${{ variables.env }}
azureSubscription: ${{ variables.subscriptionName }}
acceptanceTestSettings:
# App Insights
- name: ApplicationInsights:ConnectionString
value: connectionstrings--applicationinsights
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
# Azure AD
- name: AzureAd:ClientId
value: azuread--clientid
keyVaultName: vh-video-api-${{ variables.env }}
secret: true
- name: AzureAd:ClientSecret
value: azuread--clientsecret
keyVaultName: vh-video-api-${{ variables.env }}
secret: true
- name: AzureAd:TenantId
value: azuread--tenantid
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
# Services Configuration
- name: Services:VideoApiResourceId
value: azuread--identifieruri
keyVaultName: vh-video-api-${{ variables.env }}
secret: true
- name: Services:CallbackUri
value: $(CallbackUri)
- name: Services:VideoApiUrl
value: "https://vh-video-api.staging.platform.hmcts.net"
# Wowza Configuration
- name: WowzaConfiguration:RestApiEndpoints
value: wowzaconfiguration--endpoint-https
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StreamingEndpoint
value: wowzaconfiguration--endpoint-https
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:Username
value: wowzaconfiguration--username
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:Password
value: wowzaconfiguration--restPassword
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StorageDirectory
value: wowzaconfiguration--azure-storage-directory
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StorageAccountName
value: wowzaconfiguration--storage-account
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StorageAccountKey
value: wowzaconfiguration--storageaccountkey
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StorageContainerName
value: wowzaconfiguration--storage-account-container
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:StorageEndpoint
value: wowzaconfiguration--storage-account-endpoint
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: WowzaConfiguration:ManagedIdentityClientId
value: wowzaconfiguration--managedidentityclientid
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
# CVP Configuration
- name: CvpConfiguration:StorageAccountName
value: CvpConfiguration--StorageAccountName
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: CvpConfiguration:StorageAccountKey
value: CvpConfiguration--StorageAccountKey
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: CvpConfiguration:StorageContainerName
value: CvpConfiguration--StorageContainerName
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: CvpConfiguration:StorageEndpoint
value: CvpConfiguration--StorageEndpoint
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
# Kinly Configuration
- name: KinlyConfiguration:ConferencePhoneNumber
value: $(ConferencePhoneNumber)
- name: KinlyConfiguration:ConferencePhoneNumberWelsh
value: $(ConferencePhoneNumberWelsh)
- name: KinlyConfiguration:ApiUrl
value: $(KinlyApiUrl)
- name: KinlyConfiguration:SelfTestApiUrl
value: $(KinlySelfTestApiUrl)
- name: KinlyConfiguration:ConferenceUsername
value: $(ConferenceUsername)
- name: KinlyConfiguration:CallbackUri
value: $(CallbackUri)
- name: KinlyConfiguration:SipAddressStem
value: KinlyConfiguration--SipAddressStem
keyVaultName: vh-video-api-${{ variables.env }}
secret: true
# Vodafone Configuration
- name: VodafoneConfiguration:ConferencePhoneNumber
value: $(ConferencePhoneNumber)
- name: VodafoneConfiguration:ConferencePhoneNumberWelsh
value: $(ConferencePhoneNumberWelsh)
- name: VodafoneConfiguration:ApiUrl
value: $(VodafoneApiUrl)
- name: VodafoneConfiguration:SelfTestApiUrl
value: $(VodafoneSelfTestApiUrl)
- name: VodafoneConfiguration:ConferenceUsername
value: $(ConferenceUsername)
- name: VodafoneConfiguration:CallbackUri
value: $(CallbackUri)
- name: VodafoneConfiguration:SipAddressStem
value: VodafoneConfiguration--SipAddressStem
keyVaultName: vh-video-api-${{ variables.env }}
secret: true
# Quick Links Configuration
- name: QuickLinks:Issuer
value: $(Issuer)
- name: QuickLinks:RsaPrivateKey
value: $(RsaPrivateKey)
- name: QuickLinks:ValidAudience
value: $(ValidAudience)
#########################################
# Approve Release to Prod. ##############
- stage: Approve_Production_Release
displayName: Approve Prod Release
jobs:
- job: Approve_Production_Release
displayName: Approve Prod Release
pool: server
timeoutInMinutes: 10080 # 7 Days
steps:
- task: ManualValidation@0
timeoutInMinutes: 10080 # 7 Days
inputs:
instructions: 'Please Approve Release to Production'
onTimeout: 'reject'
#####################################################
# Run Entity Framework Prod. ########################
- stage: Run_Entity_Framework_Production
displayName: Prod EF Release
dependsOn:
- Approve_Production_Release
variables:
- template: variables/production.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Run_Entity_Framework_Production
pool:
vmImage: 'windows-latest'
displayName: Run Entity Framework Prod
steps:
- download: current
displayName: Download Sql Artifact
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: delete
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
- template: templates/Database/EntityFramework/run-entity-framework.yaml@azTemplates
parameters:
sqlServerResourceGroup: ${{ variables.vhResourceGroup }}
sqlServerName: ${{ variables.vhSQLServerName }}
databaseName: ${{ variables.videoApiDbName }}
azureSubscription: ${{ variables.subscriptionName }}
sqlScriptLocation: "$(Pipeline.Workspace)/${{ variables.efContextName }}-$(Build.BuildId)/${{ variables.efContextName }}.sql"
kvfirewallRequired: false
kvName: ${{ variables.vhKeyVault }}
kvSqlPasswordSecret: ${{ variables.vhSqlPasswordSecret }}
kvSqlUsernameSecret: ${{ variables.vhSqlUsernameSecret }}
- template: templates/Azure/Common/unlock-lock.yaml@azTemplates
parameters:
addOrDelete: add
lockName: "${{ variables.env }}-lock"
resourceGroup: ${{ variables.vhResourceGroup }}
azureSubscription: ${{ variables.subscriptionName }}
lockType: CanNotDelete
#####################################################
# Build Docker Image & Push. ########################
- stage: Docker_Build_Push_Prod
displayName: Docker Build & Push Image
dependsOn:
- Run_Entity_Framework_Production
variables:
- template: variables/production.yaml
- template: variables/shared.yaml
jobs:
- job: Docker_Build
displayName: "Docker Build and Push"
steps:
- checkout: self
- bash: |
sed -i "s|</configuration>|<packageSourceCredentials><vh-packages><add key=\"Username\" value=\"PAT\" /><add key=\"ClearTextPassword\" value=\"$(System.AccessToken)\" /></vh-packages></packageSourceCredentials></configuration>|" nuget.config
displayName: Add NuGet Feed Authentication
workingDirectory: ${{ variables.appName }}
- template: templates\Containerisation\docker\docker-compose.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
- template: templates\Containerisation\docker\docker-push-azure.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
imageName: "${{ variables.imageName }}"
imageTags:
- '${{ variables.releaseTagName }}'
- 'latest'
#########################################
# Push Helm Charts to Repo. #############
- stage: Helm_Prod
displayName: Push Helm Charts
dependsOn:
- Docker_Build_Push_Prod
variables:
- template: variables/production.yaml
- template: variables/shared.yaml
- group: vh-github-app-credentials
jobs:
- job: Helm
displayName: "Helm Push"
steps:
- checkout: self
- template: templates\Github\get-app-token.yaml@azTemplates
parameters:
privateKeyFileName: ${{ variables.gh_app_private_key_file_name }}
appId: $(gh_app_app_id)
- template: templates\Github\push-to-helm-chart-repo.yaml@azTemplates
parameters:
chartName: ${{ variables.chartName }}
chartPath: ${{ variables.chartPath }}
githubToken: $(githubappinstall.token)
githubUsername: $(gh_app_name)
githubEmail: "$(gh_app_app_id)+$(gh_app_name)[bot]@users.noreply.github.com"
subDirectory: ${{ variables.subDirectory }}