This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.sds.master-release.yml
200 lines (179 loc) · 7.14 KB
/
azure-pipelines.sds.master-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
name: $(Date:yyyyMMddHHmm)-$(Rev:r)
trigger:
- master
pr: none
resources:
repositories:
- repository: azTemplates
type: github
name: hmcts/azure-devops-templates
ref: master
endpoint: hmcts
parameters:
- name: environment
type: object
default:
- Dev
- Staging
pool:
vmImage: ubuntu-20.04
#####################################################
# Pre Run Tasks. ####################################
stages:
- stage: Pre_Run_Tasks
displayName: Pre-Release Tasks
variables:
- template: variables/shared.yaml
- template: variables/staging.yaml
jobs:
- job: Generate_Entity_Framework_Script
displayName: "Generate Entity Framework Script"
steps:
- script: |
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-3.1
- 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: package_nuget
displayName: "Package Nuget Packages"
steps:
- template: templates\dotnet\package-nuget-packages.yml@azTemplates
parameters:
nugetProjectPath: '${{ variables.appName }}/${{ variables.nuget_package_name }}'
vstsFeed: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
gitVersionConfigPath: ${{ variables.git_version_config_path }}
#####################################################
# Run Entity Framework. #############################
- ${{ each env in parameters.environment }}:
- stage: Run_Entity_Framework_${{ env }}
displayName: ${{ env }} EF Release
dependsOn: Pre_Run_Tasks
condition: and(eq(lower(dependencies.Pre_Run_Tasks.outputs['Generate_Entity_Framework_Script.git.hasChanged']), 'true'), succeeded())
variables:
- template: variables/${{ lower(env) }}.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Run_Entity_Framework_${{ env }}
displayName: Run Entity Framework ${{ env }}
pool:
vmImage: 'windows-latest' # MUST BE RUN ON WINDOWS
steps:
- download: current
displayName: Download Sql Artifact
- ${{ if eq(env, 'Staging') }}:
- 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.testApiDbName }}
azureSubscription: ${{ variables.subscriptionName }}
sqlScriptLocation: "$(Pipeline.Workspace)/${{ variables.efContextName }}-$(Build.BuildId)/${{ variables.efContextName }}.sql"
kvfirewallRequired: false
kvName: ${{ variables.vhKeyVault }}
kvSqlPasswordSecret: ${{ variables.vhSqlPasswordSecret }}
kvSqlUsernameSecret: ${{ variables.vhSqlUsernameSecret }}
- ${{ if eq(env, 'Staging') }}:
- 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_Dev
- Run_Entity_Framework_Staging
- Pre_Run_Tasks
condition: and(not(failed()), not(canceled()))
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.sds.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 }}'
#####################################################
# Deploy Nuget Packages. ############################
- stage: Push_Nuget
displayName: Deploy Nuget Packages
dependsOn:
- Run_Entity_Framework_Dev
- Run_Entity_Framework_Staging
- Pre_Run_Tasks
condition: and(not(failed()), not(canceled()))
variables:
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Publish_Nuget
displayName: Publish NuGet Packages
steps:
- template: templates\dotnet\push-nuget-packages.yml@azTemplates
parameters:
vstsFeed: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
#########################################
# Push Helm Charts to Repo. #############
- stage: Helm
displayName: Push Helm Charts
dependsOn: Docker_Build_Push
condition: succeeded('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 }}