/
azure-pipelines.yml
247 lines (214 loc) · 7.29 KB
/
azure-pipelines.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
trigger:
- master
pr:
- master
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
stages:
- stage: Build
jobs:
- job: BuildNet6
displayName: '.NET 6 WebApp'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: 'Install GitVersion'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global GitVersion.Tool --version 5.5.0'
- task: DotNetCoreCLI@2
displayName: 'Update Version'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: '/output buildserver /nofetch'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
projects: 'wwt-website-net6.slnf'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: 'test'
projects: 'wwt-website-net6.slnf'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: dotnet publish
inputs:
command: 'publish'
publishWebProjects: false
zipAfterPublish: true
modifyOutputPath: true
projects: 'src/WWT.Web/WWT.Web.csproj'
arguments: '--configuration $(buildConfiguration) -o $(Build.ArtifactStagingDirectory)/website'
- task: DotNetCoreCLI@2
displayName: Create tool package
inputs:
command: 'pack'
packagesToPack: 'tools/PlateManager/PlateManager.csproj'
packDirectory: '$(Build.ArtifactStagingDirectory)/tools'
versioningScheme: 'off'
- publish: $(build.artifactStagingDirectory)/tools
displayName: Publish tools
artifact: tools
- publish: $(build.artifactStagingDirectory)/website
displayName: Publish net6-web
artifact: net6-web
- job: BuildMVC5
displayName: 'ASP.NET MVC5 WebApp'
pool:
vmImage: 'windows-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: 'Install GitVersion'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global GitVersion.Tool --version 5.5.0'
- task: DotNetCoreCLI@2
displayName: 'Update Version'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: '/output buildserver /nofetch'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: 'wwt-website.sln'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: Npm@1
displayName: npm install
inputs:
command: 'install'
workingDir: 'src/WWTMVC5'
- task: Npm@1
displayName: npm install -g bower
inputs:
command: 'custom'
customCommand: 'install -g bower'
- task: PowerShell@2
displayName: Run init.ps1
inputs:
filePath: 'init.ps1'
- task: VSBuild@1
inputs:
solution: 'wwt-website.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:EnableUpdateable=false /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)/website"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
projects: 'wwt-website-net6.slnf'
arguments: '--configuration $(buildConfiguration)'
- publish: $(build.artifactStagingDirectory)/website
artifact: mvc5
- job: BuildDocker
displayName: 'Docker Image'
pool:
vmImage: 'Ubuntu-latest'
steps:
- task: Docker@2
displayName: Build image
inputs:
repository: 'aasworldwidetelescope/core-data'
command: 'build'
Dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
buildContext: '$(Build.SourcesDirectory)'
tags: |
latest
- bash: |
set -xeuo pipefail
mkdir $(build.artifactStagingDirectory)/dockerImage
docker save -o $(build.artifactStagingDirectory)/dockerImage/core-data.tar.gz \
aasworldwidetelescope/core-data:latest
displayName: Save image as artifact
- publish: $(build.artifactStagingDirectory)/dockerImage
artifact: dockerImage
- stage: Deploy
dependsOn: Build
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
jobs:
- job: Tools
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: tools
- task: DotNetCoreCLI@2
displayName: Push tools to feed
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/tools/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '5b8413f0-309f-4655-933b-c3b9516cd60f/cec2a436-ea5b-41d3-a4d4-8f2380a4c6a9'
# This job deploys the updated Windows app to the "stage" deployment slot of
# the Windows app service. To bring those changes into production, the stage
# and main slots should be "swapped" in the Azure UI, after warming up the
# new app and doing any final testing.
- job: AzureAppService
pool:
vmImage: 'windows-latest'
steps:
- checkout: none
- download: current
artifact: mvc5
- task: AzureRmWebAppDeployment@4
displayName: Deploy to App Service
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'aas@wwtadmindotnetfoundation'
appType: 'webApp'
WebAppName: 'wwtcoreapp-app-service'
deployToSlotOrASE: true
ResourceGroupName: 'wwtcoreapp-resources'
SlotName: 'stage'
packageForLinux: '$(Pipeline.Workspace)/mvc5/WWTMVC5.zip'
DeploymentType: 'webDeploy'
RemoveAdditionalFilesFlag: true
# This job deploys the new Docker image to Docker Hub under the `latest`
# tag, which will then trigger an update of the "stage" deployment slot of
# the Linux core data app service. To bring the new image into production,
# the stage and main slots should be "swapped" in the Azure UI, after
# warming up the new app and doing any final testing.
- job: DockerImage
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: dockerImage
- bash: |
docker load -i $(Pipeline.Workspace)/dockerImage/core-data.tar.gz
displayName: Load image from artifacts
- task: Docker@2
displayName: Push image
inputs:
containerRegistry: 'worldwidetelescope@DockerHub'
repository: 'aasworldwidetelescope/core-data'
command: 'push'
tags: |
latest