-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
130 lines (122 loc) · 4.15 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
trigger:
branches:
include:
- master
schedules:
- cron: "0 0,12 * * *"
always: true
displayName: Reset DNS Every 12 Hours
branches:
include:
- master
name: 1.0.$(BuildID)
variables:
- group: keyvault_variables
stages:
- stage: build
jobs:
- job: check_and_preview
displayName: 'Run DNSControl check and preview'
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
persistCredentials: true
clean: true
- task: replacetokens@3
displayName: 'Replace variables in files'
inputs:
targetFiles: |
creds.json
dnsconfig.js
encoding: 'auto'
writeBOM: true
actionOnMissing: 'fail'
keepToken: false
tokenPrefix: '#{'
tokenSuffix: '}#'
- task: Docker@1
displayName: 'Run DNSControl Check'
inputs:
containerregistrytype: 'Container Registry'
command: 'Run an image'
imageName: stackexchange/dnscontrol
qualifyImageName: false
volumes: '$(System.DefaultWorkingDirectory)/:/dns'
containerCommand: 'dnscontrol check'
runInBackground: false
- task: Docker@1
displayName: 'Run DNSControl Preview'
inputs:
containerregistrytype: 'Container Registry'
command: 'Run an image'
imageName: stackexchange/dnscontrol
qualifyImageName: false
volumes: '$(System.DefaultWorkingDirectory)/:/dns'
containerCommand: 'dnscontrol preview'
runInBackground: false
- stage: release
dependsOn: build
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
jobs:
- deployment: DeployProduction
displayName: 'Run DNSControl push'
pool:
vmImage: ubuntu-latest
environment: 'DNS Production'
strategy:
runOnce:
deploy:
steps:
- checkout: self
persistCredentials: true
clean: true
- task: replacetokens@3
displayName: 'Replace variables in files'
inputs:
targetFiles: |
creds.json
dnsconfig.js
encoding: 'auto'
writeBOM: true
actionOnMissing: 'fail'
keepToken: false
tokenPrefix: '#{'
tokenSuffix: '}#'
- task: Docker@1
displayName: 'Run DNSControl push'
inputs:
containerregistrytype: 'Container Registry'
command: 'Run an image'
imageName: stackexchange/dnscontrol
qualifyImageName: false
volumes: '$(System.DefaultWorkingDirectory)/:/dns'
containerCommand: 'dnscontrol push'
runInBackground: false
- powershell: |
if (test-path "$(System.DefaultWorkingDirectory)/spfcache.updated.json") {
move-item "$(System.DefaultWorkingDirectory)/spfcache.updated.json" "$(System.DefaultWorkingDirectory)/DNSControl/spfcache.json" -Force
git config user.email "$(email)"
git config user.name "$(name)"
git add spfcache.json
git commit -m "Updated spfcache.json ***NO_CI***"
if (('$(Build.Repository.Uri)').contains('github')) {
# If GitHub, need PAT etc
git push https://$(Github-pat)@github.com/$(Github-org)/$(Github-repo).git HEAD:master
} else {
git push origin HEAD:master
}
}
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Commit spfcache.json back'
- powershell: |
git tag v$(Build.BuildNumber)
if (('$(Build.Repository.Uri)').contains('github')) {
# If GitHub, need PAT etc
git push https://$(Github-pat)@github.com/$(Github-org)/$(Github-repo).git HEAD:master
} else {
git push origin HEAD:master
}
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Tag Release Number'
condition: and(succeeded(), ne(variables['Build.Reason'], 'Schedule'))