-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
264 lines (260 loc) · 9.97 KB
/
azure-pipelines.yml
File metadata and controls
264 lines (260 loc) · 9.97 KB
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
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
# See License in the project root for license information.
# ------------------------------------------------------------------------------
#
# 1. Validates the repository's pull requests and commits
# 2. Builds and publishes release artifacts
# 3. This pipeline will be extended to the OneESPT template
name: $(date:yyyyMMdd)$(rev:.r)
pr:
branches:
include:
- master
- dev
- feature/*
- task/*
- fix/*
paths:
exclude:
- .github/*
- .vscode/*
- build/*
- .gitignore
- .prettierrc
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- README.md
- azure-pipelines.yml
- package-lock.json
variables:
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isDev: $[eq(variables['Build.SourceBranch'], 'refs/heads/dev')]
trigger:
branches:
include:
- master
- dev
- feature/*
- task/*
- fix/*
paths:
exclude:
- .github/*
- .vscode/*
- build/*
- .gitignore
- .prettierrc
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- README.md
- azure-pipelines.yml
- package-lock.json
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
- repository: ReleasePipelines
type: git
name: "Graph Developer Experiences/release-pipelines"
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
sdl:
sourceRepositoriesToScan:
exclude:
- repository: ReleasePipelines
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: BuildTestAndPublish
jobs:
- job: One
displayName: "Build and test validation"
steps:
- task: ComponentGovernanceComponentDetection@0
inputs:
scanType: "Register"
verbosity: "Verbose"
alertWarningLevel: "High"
ignoreDirectories: ".github,.vscode/"
- task: NodeTool@0
inputs:
versionSpec: "25.x"
displayName: "Install Node.js"
- script: |
npm ci
displayName: "npm ci"
- script: |
npm run lint
displayName: "Runs linting checks"
- script: |
npm test
displayName: "Runs Unit tests"
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: "JUnit"
testResultsFiles: "test-report.xml"
displayName: "Publish Test Results"
- script: |
npm run build
displayName: "Run build"
- job: Two
displayName: "Publish artifacts"
dependsOn: One
steps:
- task: NodeTool@0
inputs:
versionSpec: "25.x"
displayName: "Install Node.js"
- script: |
npm ci
displayName: "npm ci"
- script: |
npm run build
env:
REACT_APP_CLIENT_ID: $(REACT_APP_STAGING_CLIENT_ID)
REACT_APP_INSTRUMENTATION_KEY: $(REACT_APP_STAGING_INSTRUMENTATION_KEY)
REACT_APP_CONNECTION_STRING: $(REACT_APP_STAGING_CONNECTION_STRING)
REACT_APP_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_STAGING_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NOMINATION_PERIOD: $(REACT_APP_NOMINATION_PERIOD)
REACT_APP_COOLDOWN_PERIOD: $(REACT_APP_COOLDOWN_PERIOD)
REACT_APP_USAGE_TIME: $(REACT_APP_USAGE_TIME)
REACT_APP_DEVX_API_URL: $(REACT_APP_DEVX_API_URL)
REACT_APP_MIGRATION_PARAMETER: $(REACT_APP_MIGRATION_PARAMETER)
displayName: "Build static assets for staging"
- task: PowerShell@2
displayName: "Set version-number"
condition: and(succeeded(), eq(variables['isMaster'], 'true'))
inputs:
targetType: "inline"
script: |
$lernaPath = "$Env:BUILD_SOURCESDIRECTORY\package.json"
$json = Get-Content "$lernaPath" | Out-String | ConvertFrom-Json
$versionNumber = $json.version;
Write-Host "Setting the build number variable to '$versionNumber'."
Write-Host "##vso[build.updatebuildnumber]$versionNumber"
- script: |
npm run build
condition: and(succeeded(), eq(variables['isMaster'], 'true'))
env:
REACT_APP_CLIENT_ID: $(REACT_APP_PROD_CLIENT_ID)
REACT_APP_INSTRUMENTATION_KEY: $(REACT_APP_INSTRUMENTATION_KEY)
REACT_APP_CONNECTION_STRING: $(REACT_APP_CONNECTION_STRING)
REACT_APP_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NOMINATION_PERIOD: $(REACT_APP_NOMINATION_PERIOD)
REACT_APP_COOLDOWN_PERIOD: $(REACT_APP_COOLDOWN_PERIOD)
REACT_APP_USAGE_TIME: $(REACT_APP_USAGE_TIME)
REACT_APP_DEVX_API_URL: $(REACT_APP_DEVX_API_URL)
REACT_APP_MIGRATION_PARAMETER: $(REACT_APP_MIGRATION_PARAMETER)
displayName: "Build static assets for prod"
- task: PowerShell@2
displayName: "Create _manifest directory"
inputs:
targetType: "inline"
script: |
$manifestPath = "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/_manifest"
mkdir -p $manifestPath
Write-Host "Created directory '$manifestPath'."
- task: ManifestGeneratorTask@0
inputs:
ManifestDirPath: "$(System.DefaultWorkingDirectory)/_manifest"
BuildComponentPath: "$(System.DefaultWorkingDirectory)/build"
PackageName: "graph-explorer-v2"
PackageVersion: "$(Build.UpdateBuildNumber)"
- task: CopyFiles@1
displayName: "Copy manifest files to artifact staging dir: manifest"
inputs:
SourceFolder: "$(System.DefaultWorkingDirectory)/_manifest"
TargetFolder: "$(Build.ArtifactStagingDirectory)/manifest"
- task: CopyFiles@1
displayName: "Copy files to: $(Build.ArtifactStagingDirectory)/build"
inputs:
SourceFolder: "$(System.DefaultWorkingDirectory)/build"
TargetFolder: "$(Build.ArtifactStagingDirectory)/build"
- task: DeleteFiles@1
inputs:
contents: node_modules
displayName: "Delete node_modules"
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/build/graph-explorer.zip'
replaceExistingArchive: true
templateContext:
outputs:
- output: pipelineArtifact
displayName: 'Publish Artifact: manifest'
targetPath: "$(Build.ArtifactStagingDirectory)/manifest"
artifactName: manifest
- output: pipelineArtifact
displayName: 'Publish Artifact: drop'
targetPath: "$(build.ArtifactStagingDirectory)/build"
artifactName: drop
- template: pipelines/templates/checkout-and-copy-1es.yml@ReleasePipelines
parameters:
directory: 'microsoft-graph-explorer-v4'
repoName: ReleasePipelines
dependsOn: ['Two']
- stage: DeployProduction
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded())
dependsOn: BuildTestAndPublish
jobs:
- deployment: production
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
artifactName: drop
targetPath: '$(Build.ArtifactStagingDirectory)/drop'
environment: graphexplorer-production
strategy:
runOnce:
deploy:
steps:
- task: AzureFileCopy@6
displayName: 'Deploy to portal - staging'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/drop/*'
azureSubscription: 'Federated Portals Managed Identity Connection'
Destination: AzureBlob
storage: graphstagingblobstorage
ContainerName: staging
BlobPrefix: 'vendor/bower_components/explorer$(Build.BuildNumber)/build'
- task: AzureFileCopy@6
displayName: 'Deploy to portal - production'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/drop/*'
azureSubscription: 'Federated Portals Managed Identity Connection'
Destination: AzureBlob
storage: graphprodblobstorage
ContainerName: prod
BlobPrefix: 'vendor/bower_components/explorer$(Build.BuildNumber)/build'
- task: ArchiveFiles@2
displayName: 'Archive built assets'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/drop/'
archiveFile: '$(Build.ArtifactStagingDirectory)/graph-explorer-$(Build.BuildNumber)-$(Build.BuildId).zip'
- task: GitHubRelease@1
displayName: 'GitHub release (v$(Build.BuildNumber)-$(Build.BuildId))'
inputs:
gitHubConnection: 'GitHub - thewahome'
action: edit
tag: 'v$(Build.BuildNumber)'
title: 'Graph Explorer - v$(Build.BuildNumber)'
assets: '$(Build.ArtifactStagingDirectory)/*.zip'
changeLogType: issueBased