-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
108 lines (91 loc) · 4.53 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
trigger:
batch: 'true'
branches:
include:
- master
- development
- development-*
resources:
pipelines:
- pipeline: 'ModulesDotNetPipeline'
source: 'IntentSoftware.Intent.Modules.NET'
trigger: true
- pipeline: 'ModulesCommonPipeline'
source: 'IntentSoftware.Intent.Modules'
trigger: true
parameters:
- name: modules
type: object
default:
- repositoryName: modules-dotnet
repositoryUrl: https://github.com/IntentArchitect/Intent.Modules.NET.git
folderName: Intent.Modules.NET
destinationFolder: modules-dotnet
- repositoryName: 'modules-common'
repositoryUrl: "https://github.com/IntentArchitect/Intent.Modules.git"
folderName: Intent.Modules
destinationFolder: modules-common
variables:
- group: 'Pipeline Agent Pool Names'
pool:
name: $(BuildPool.AzureManaged)
demands:
- 'ImageOverride -equals ubuntu-latest'
steps:
# checkout the branch docs repo
- checkout: self
persistCredentials: 'true'
fetchDepth: '1'
displayName: 'Checkout Docs branch'
# calculate the repo and branch which triggered this pipeline
- powershell: |
if ("$(Resources.TriggeringAlias)" -eq "ModulesDotNetPipeline") {
Write-Host "##vso[task.setvariable variable=triggeredByPipeline]IntentSoftware.Intent.Modules.NET"
Write-Host "##vso[task.setvariable variable=triggeredByBranch]$(resources.pipeline.ModulesDotNetPipeline.sourceBranch)"
$branchName = "$(resources.pipeline.ModulesDotNetPipeline.sourceBranch)" -replace '^refs/heads/', ''
Write-Host "##vso[task.setvariable variable=triggeredByBranchNameOnly]$branchName"
}
elseif ("$(Resources.TriggeringAlias)" -eq "ModulesCommonPipeline") {
Write-Host "##vso[task.setvariable variable=triggeredByPipeline]IntentSoftware.Intent.Modules"
Write-Host "##vso[task.setvariable variable=triggeredByBranch]$(resources.pipeline.ModulesCommonPipeline.sourceBranch)"
$branchName = "$(resources.pipeline.ModulesCommonPipeline.sourceBranch)" -replace '^refs/heads/', ''
Write-Host "##vso[task.setvariable variable=triggeredByBranchNameOnly]$branchName"
}
else {
Write-Host "##vso[task.setvariable variable=triggeredByPipeline]IntentSoftware.Docs"
Write-Host "##vso[task.setvariable variable=triggeredByBranch]$(Build.SourceBranchName)"
$branchName = "$(Build.SourceBranchName)" -replace '^refs/heads/', ''
Write-Host "##vso[task.setvariable variable=triggeredByBranchNameOnly]$branchName"
}
displayName: 'Determine and Set Variables for Triggered Pipeline'
- pwsh: |
Write-Host "Triggered By Pipeline: $(triggeredByPipeline)"
Write-Host "Triggered By Branch: $(triggeredByBranch)"
Write-Host "Triggered By BranchNameOnly: $(triggeredByBranchNameOnly)"
displayName: 'Output pipeline variables'
# first clean just to make sure all fresh incase
- pwsh: |
git clean -fdx
displayName: '$git clean'
# for each of the above configured modules (under parameters)
- ${{ each module in parameters.modules }} :
- task: PowerShell@2
displayName: "${{ module.repositoryName }} Module Merge"
inputs:
targetType: 'inline'
pwsh: true
script: ./PipelineScripts/merge-repo-docs.ps1 "$(triggeredByBranchNameOnly)" "${{ module.repositoryUrl }}" "${{ module.folderName }}" "${{ module.destinationFolder }}" 1
- pwsh: |
dotnet tool install docfx
displayName: 'dotnet tool install docfx'
- pwsh: |
dotnet docfx $(Build.SourcesDirectory)/docfx.json
displayName: 'run docfx'
- pwsh: |
az storage blob sync -s '$(Build.SourcesDirectory)/_site' -d '$(triggeredByBranchNameOnly)/' --container '$(intentarchitect.storageContainer)' --account-name '$(intentarchitect.preprod.storageAccountName)' --account-key '$(intentarchitect.preprod.storageAccountKey)' --delete-destination 'true'
displayName: 'Pre-production storage sync'
condition: and(succeeded(), ne(variables['triggeredByBranch'], 'master'), ne(variables['triggeredByBranch'], 'refs/heads/master'))
- pwsh: |
az storage blob sync -s '$(Build.SourcesDirectory)/_site' --container '$(intentarchitect.storageContainer)' --account-name '$(intentarchitect.storageAccountName)' --account-key '$(intentarchitect.storageAccountKey)' --delete-destination 'true'
displayName: 'Production storage sync'
condition: and(succeeded(), or(eq(variables['triggeredByBranch'], 'master'), eq(variables['triggeredByBranch'], 'refs/heads/master')))