-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
azure-pipelines.yml
125 lines (109 loc) · 3.11 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
name: '$(Date:yyyy)-$(Date:MM)-$(Date:dd)$(Rev:.r)'
trigger:
batch: true
branches:
include:
- main
- refs/tags/*
pr:
branches:
include:
- main
drafts: false
autoCancel: true
paths:
include:
- server/**
- azure-pipelines.yml
exclude:
- docs/**
stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
fetchDepth: 0 # no shallow fetch, we need all the history for GitVersion to work
- task: gitversion/setup@0
displayName: Setup GitVersion
inputs:
versionSpec: '5.x'
- task: gitversion/execute@0
displayName: Determine Version
name: GitVersion
inputs:
useConfigFile: true
configFilePath: '$(Build.SourcesDirectory)/GitVersion.yml'
- task: replacetokens@3
displayName: 'Replace tokens in main.parameters.json'
inputs:
rootDirectory: '$(Build.SourcesDirectory)/server'
targetFiles: 'main.parameters.json'
actionOnMissing: fail
verbosity: detailed
# Compile bicep file to JSON to make it independent
- script: |
bicep build main.bicep --outfile main.json
displayName: 'Compile bicep file'
workingDirectory: $(Build.SourcesDirectory)/server
- task: CopyFiles@2
displayName: 'Copy files to drop folder'
inputs:
SourceFolder: $(Build.SourcesDirectory)/server
Contents: |
*.json
TargetFolder: $(Build.ArtifactStagingDirectory)/drop
- task: PublishPipelineArtifact@1
displayName: "Publish drop artifact"
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/drop
artifactName: "drop"
- task: AzureCLI@2
displayName: "Validate Resources"
condition: |
and
(
succeeded(),
startsWith(variables['Build.SourceBranch'], 'refs/pull/')
)
inputs:
azureSubscription: $(azureConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: >
az deployment group validate
--resource-group '$(resourceGroupName)'
--template-file $(Build.SourcesDirectory)/server/main.json
--parameters $(Build.SourcesDirectory)/server/main.parameters.json
- stage: Deploy
displayName: Deploy
dependsOn: Build
# only deploy non pr branches
condition: |
and
(
succeeded(),
not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
)
jobs:
- deployment: Deploy
environment: Dependabot
pool:
vmImage: 'ubuntu-latest'
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
displayName: "Deploy Resources"
inputs:
azureSubscription: $(azureConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: >
az deployment group create
--resource-group '$(resourceGroupName)'
--template-file $(Pipeline.Workspace)/drop/main.json
--parameters $(Pipeline.Workspace)/drop/main.parameters.json