-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
193 lines (164 loc) · 6.37 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
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
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: "windows-latest"
variables:
ARTIFACT_NAME: DevelopMomentumWeb
stages:
- stage: Build
displayName: Build
jobs:
- job: Transform
displayName: Transform Input
variables:
project: "src/Blog.csproj"
buildConfiguration: "Release"
steps:
- task: replacetokens@3
displayName: "Replace Variables"
inputs:
targetFiles: |
src/input/**/*.html
src/input/**/*.cshtml
src/input/**/*.md
src/input/**/*.yml
src/input/**/*.json
encoding: "auto"
writeBOM: true
actionOnMissing: "warn"
keepToken: true
tokenPrefix: "#{"
tokenSuffix: "}#"
useLegacyPattern: false
enableTelemetry: false
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: "restore"
projects: $(project)
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: "build"
projects: "$(project)"
arguments: "--configuration $(buildConfiguration)"
workingDirectory: "src"
- task: DotNetCoreCLI@2
displayName: Generate
inputs:
command: "run"
projects: "$(project)"
arguments: "--configuration $(buildConfiguration)"
workingDirectory: "src"
- task: CopyFiles@2
displayName: Copy
inputs:
SourceFolder: "$(Build.SourcesDirectory)/src/output"
Contents: "**"
TargetFolder: "$(Build.ArtifactStagingDirectory)/output"
- task: PublishPipelineArtifact@1
displayName: Share
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/output"
artifact: "$(ARTIFACT_NAME)"
publishLocation: "pipeline"
- stage: Staging
displayName: Staging
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeployToSkynet
displayName: Deploy to Sia Skynet
environment: developmomentum-staging
strategy:
runOnce:
deploy:
steps:
- task: Sia-Skynet-Upload@0
displayName: "Upload to https://skynetfree.net"
name: website_upload
inputs:
portal: "https://skynetfree.net"
path: "$(Pipeline.Workspace)/$(ARTIFACT_NAME)"
- powershell: |
New-Item -Path $(Pipeline.Workspace) -Name variables -ItemType directory
Write-Output $(website_upload.skylink) > $(Pipeline.Workspace)/variables/skylink
displayName: Write to File
- publish: $(Pipeline.Workspace)/variables
artifact: variables
displayName: Share
- stage: Release
displayName: Release
dependsOn: Staging
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- deployment: DeployToStorage
displayName: Deploy to Azure Storage
environment: developmomentum-production
variables:
AZURE_STORAGE_ACCOUNT: developmomentum
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
displayName: "Delete Existing Files"
inputs:
azureSubscription: "Pay-As-You-Go (8df2aaab-fa1b-4031-9a60-43ebee006b38)"
scriptType: "pscore"
scriptLocation: "inlineScript"
inlineScript: "az storage blob delete-batch -s `$web --account-name $(AZURE_STORAGE_ACCOUNT) --auth-mode login"
- script: reg add HKCR\.js /v "Content Type" /d application/javascript /f
displayName: Add .js content type to registry
- task: AzureFileCopy@4
displayName: "Copy Files to Storage"
inputs:
azureSubscription: "Pay-As-You-Go (8df2aaab-fa1b-4031-9a60-43ebee006b38)"
SourcePath: "$(Pipeline.Workspace)/$(ARTIFACT_NAME)/*"
Destination: "AzureBlob"
storage: "$(AZURE_STORAGE_ACCOUNT)"
ContainerName: "$web"
routeTraffic:
steps:
- task: PurgeAzureCDNEndpoint@2
displayName: "Purge Azure CDN Endpoint"
inputs:
ConnectedServiceNameSelector: ConnectedServiceNameARM
ConnectedServiceNameARM: "Pay-As-You-Go (8df2aaab-fa1b-4031-9a60-43ebee006b38)"
ResourceGroupName: developmomentum
EndpointName: developmomentum
ProfileName: developmomentum
continueOnError: true
- task: tfx-cloudflare-purge@1
displayName: "Purge Cloudflare Cache"
inputs:
username: "[email protected]"
apikey: "$(CLOUDFLARE_API_KEY)"
zonename: developmomentum.com
continueOnError: true
- job: PublishToSkynet
displayName: Publish to Sia Skynet
steps:
- download: current
artifact: variables
displayName: "Retrieve Variables"
- powershell: |
$skylink = Get-Content $(Pipeline.Workspace)/variables/skylink
Write-Output "##vso[task.setvariable variable=skylink]$skylink"
displayName: "Populate Variable"
- task: GitHubRelease@1
displayName: "Tag"
inputs:
gitHubConnection: "github.com_drmathias"
repositoryName: "drmathias/developmomentum"
action: "create"
target: "$(Build.SourceVersion)"
tagSource: "userSpecifiedTag"
tag: "$(Build.BuildNumber)"
releaseNotesSource: "inline"
releaseNotesInline: "sia://$(skylink)"
addChangeLog: false