forked from dotnet/source-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
215 lines (185 loc) · 6.03 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
schedules:
- cron: 0 10 * * *
displayName: Every day at 10:00 UTC
branches:
include:
- main
always: true
jobs:
- job: BuildIndex
displayName: Build Source Index
pool:
name: NetCore1ESPool-Internal-XL
demands: ImageOverride -equals 1es-windows-2022
timeoutInMinutes: 360
variables:
- group: source-dot-net stage1 variables
steps:
- checkout: self
clean: true
submodules: true
- task: DeleteFiles@1
displayName: Delete files from bin
inputs:
SourceFolder: bin
Contents: '**/*'
- task: UseDotNet@2
displayName: Install .NET Sdk
inputs:
useGlobalJson: true
- task: UseDotNet@2
displayName: Install .NET 6.0 runtime
inputs:
packageType: runtime
version: 6.0.x
- script: |
dotnet tool restore
dotnet script deployment/AllowPrereleaseSdks.csx
displayName: Check Allow Prerelease Sdks
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: custom
custom: restore
projects: |
**\*.sln
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
projects: |
src\source-indexer.sln
src\SourceBrowser\SourceBrowser.sln
arguments: '/p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/packages'
- task: ComponentGovernanceComponentDetection@0
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/packages/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '9ee6d478-d288-47f7-aacc-f6e6d082ae6d/d1622942-d16f-48e5-bc83-96f4539e7601'
- task: VSBuild@1
displayName: Clone All Repositories
inputs:
solution: build.proj
msbuildArgs: /t:Clone /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/clone.binlog
msbuildArchitecture: x64
env:
source-dot-net-stage1-blob-container-url: $(source-dot-net-stage1-blob-container-url)
- task: VSBuild@1
displayName: Prepare All Repositories
inputs:
solution: build.proj
msbuildArgs: /t:Prepare /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/prepare.binlog
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build source index
inputs:
solution: build.proj
msbuildArgs: /t:BuildIndex /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/build.binlog
msbuildArchitecture: x64
- powershell: |
deployment/install-tool.ps1 -Name 'azure-cli' -Version 2.8.0 -TestPath '/wbin/az.cmd' -BinPath '/wbin/'
displayName: 'Install Az CLI 2.8.0'
- powershell: |
deployment/install-tool.ps1 -Name 'azcopy' -Version 10.2.1
displayName: 'Install AzCopy 10.2.1'
- task: CopyFiles@2
inputs:
sourceFolder: bin/index/
contents: |
**
!index/**
targetFolder: bin/index-stage/
cleanTargetFolder: true
- powershell: deployment/normalize-case.ps1 -Root bin/index/index/
displayName: Normalize Case Of Index Files
- task: AzureCLI@2
displayName: Upload Index to Azure Storage
inputs:
azureSubscription: DncEng-VSTS
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/upload-index-to-container.ps1
-StorageAccountName netsourceindex
-IndexSource bin/index/index/
-OutFile bin/index.url
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: netsourceindex'
inputs:
ConnectionType: AzureRM
azureSubscription: DncEng-VSTS
appType: webApp
WebAppName: netsourceindex
ResourceGroupName: source.dot.net
deployToSlotOrASE: true
SlotName: staging
packageForLinux: bin/index-stage/
enableCustomDeployment: true
DeploymentType: webDeploy
RemoveAdditionalFilesFlag: true
- task: AzureCLI@2
displayName: Deploy Storage Proxy Url to WebApp
inputs:
azureSubscription: DncEng-VSTS
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/deploy-storage-proxy.ps1
-ProxyUrlFile bin/index.url
-ResourceGroup source.dot.net
-WebappName netsourceindex
-Slot staging
- task: AzureCLI@2
displayName: Restart WebApp
inputs:
azureSubscription: DncEng-VSTS
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
az webapp restart --name netsourceindex --slot staging --resource-group source.dot.net
- pwsh: |
Start-Sleep 60
$urls = @(
"https://netsourceindex-staging.azurewebsites.net",
"https://netsourceindex-staging.azurewebsites.net/System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.cs.html"
)
foreach ($url in $urls) {
$statusCode = Invoke-WebRequest $url -UseBasicParsing -SkipHttpErrorCheck | select -ExpandProperty StatusCode
if ($statusCode -ne 200) {
Write-Host "##vso[task.logissue type=error;]Deployed website returned undexpected status code $statusCode from url $url"
Write-Host "##vso[task.complete result=Failed;]Deployed website returned undexpected status code $statusCode from url $url"
}
}
displayName: Test Deployed WebApp
- task: AzureCLI@2
displayName: Swap Staging Slot into Production
inputs:
azureSubscription: DncEng-VSTS
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
az webapp deployment slot swap
--resource-group source.dot.net
--name netsourceindex
--slot staging
--target-slot production
- task: AzureCLI@2
displayName: Cleanup Old Storage Containers
inputs:
azureSubscription: DncEng-VSTS
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/cleanup-old-containers.ps1
-ResourceGroup source.dot.net
-WebappName netsourceindex
-StorageAccountName netsourceindex
- publish: $(Build.ArtifactStagingDirectory)/logs
artifact: logs
condition: always()
- publish: bin/repo
artifact: repo-logs
condition: always()