-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrontend-azure-pipeline.yml
156 lines (135 loc) · 5.4 KB
/
frontend-azure-pipeline.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
trigger:
branches:
include:
- main
- feature/*
paths:
include:
- client
- cicd
pool:
vmImage: ubuntu-latest
stages:
- stage: build
jobs:
- job: build
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.1.x'
displayName: 'Set SDK to 3.1.x'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '$(Build.SourcesDirectory)/client/client.csproj'
displayName: 'Build client'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '$(Build.SourcesDirectory)/client/client.csproj'
arguments: '-o $(Build.ArtifactStagingDirectory)'
displayName: 'dotnet publish'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.SourcesDirectory)/infrastructure'
artifact: 'infrastructure'
publishLocation: 'pipeline'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- stage: prereqs
jobs:
- job: prereqs
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'infrastructure'
targetPath: '$(System.DefaultWorkingDirectory)'
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'GitWatcher'
subscriptionId: '$(SUBSCRIPTIONID)'
action: 'Create Or Update Resource Group'
resourceGroupName: 'azl-tfstate-shared-ukw-rg'
location: 'UK South'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/infrastructure/state-backend/state-backend.azuredeploy.json'
deploymentMode: 'Incremental'
- stage: dev
variables:
location: UKWest
location_short_code: ukw
shortcode: azl
product: gwfe
environment_name: dev
backendAzureRmContainerName: tfstate
backendAzureRmKey: devclient
backendStorageAccount: tfstatedlm4lgkvg3eey
resource_group_tfstate: azl-tfstate-shared-ukw-rg
jobs:
- job: dev
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
steps:
- task: TerraformInstaller@0
inputs:
terraformVersion: '0.14.7'
- task: replacetokens@3
inputs:
rootDirectory: '$(System.DefaultWorkingDirectory)/infrastructure/client'
targetFiles: '**/*.tfvars'
encoding: 'auto'
writeBOM: true
actionOnMissing: 'warn'
keepToken: false
tokenPrefix: '__'
tokenSuffix: '__'
useLegacyPattern: false
enableTransforms: false
enableTelemetry: true
- task: TerraformTaskV1@0
displayName: 'Terraform Init'
inputs:
provider: 'azurerm'
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/infrastructure/client'
backendServiceArm: 'GitWatcher'
backendAzureRmResourceGroupName: '$(resource_group_tfstate)'
backendAzureRmStorageAccountName: '$(backendStorageAccount)'
backendAzureRmContainerName: '$(backendAzureRmContainerName)'
backendAzureRmKey: '$(backendAzureRmKey)'
- task: TerraformTaskV1@0
displayName: 'Terraform plan'
inputs:
provider: 'azurerm'
command: 'plan'
workingDirectory: '$(System.DefaultWorkingDirectory)/infrastructure/client'
commandOptions: '-var-file="$(System.DefaultWorkingDirectory)/infrastructure/client/az-storage-account-client-variables.tfvars" --out=planfile'
environmentServiceNameAzureRM: 'GitWatcher'
backendServiceArm: 'GitWatcher'
backendAzureRmResourceGroupName: '$(resource_group_tfstate)'
backendAzureRmStorageAccountName: '$(backendStorageAccount)'
backendAzureRmContainerName: $(backendAzureRmContainerName)
backendAzureRmKey: '$(backendAzureRmKey)'
- task: TerraformTaskV1@0
displayName: 'Terraform apply'
inputs:
provider: 'azurerm'
command: 'apply'
workingDirectory: '$(System.DefaultWorkingDirectory)/infrastructure/client'
commandOptions: '-auto-approve planfile'
environmentServiceNameAzureRM: 'GitWatcher'
backendServiceArm: 'GitWatcher'
backendAzureRmResourceGroupName: '$(resource_group_tfstate)'
backendAzureRmStorageAccountName: '$(storageAccountName)'
backendAzureRmContainerName: $(backendAzureRmContainerName)
backendAzureRmKey: '$(backendAzureRmKey)'