-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-build-and-publish.yml
94 lines (84 loc) · 2.97 KB
/
azure-build-and-publish.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
# This template is referenced in the repositories for various WWT guides to
# define their CI/CD mechanism. Note that while the guides include this
# repository as a Git submodule, Azure Pipelines doesn't support that, so it
# is possible that the version of this file used by Pipelines won't be in sync
# with what the guide repository expects.
#
# This pipeline has to run on Windows in order to take advantage of the
# AzureFileCopy task.
parameters:
- name: 'azureServiceConnectionName'
type: string
- name: 'cdnProfileName'
default: 'skip'
type: string
- name: 'cdnPubPrefix'
default: 'unspecified'
type: string
- name: 'cdnEndpointName'
default: 'unspecified'
type: string
- name: 'cdnResourceGroupName'
default: 'unspecified'
type: string
- name: 'containerName'
default: '$web'
type: string
- name: 'pubPrefix'
type: string
- name: 'storageAccountName'
type: string
- name: 'vmImage'
default: 'windows-latest'
type: string
- name: 'zolaVersion'
default: '0.15.2'
type: string
jobs:
- job: BuildAndPublish
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- checkout: self
submodules: recursive
- pwsh: |
$u = 'https://github.com/getzola/zola/releases/download/v${{ parameters.zolaVersion }}/zola-v${{ parameters.zolaVersion }}-x86_64-pc-windows-msvc.zip'
Invoke-WebRequest -Uri $u -OutFile zola.zip
Add-Type -assembly "System.IO.Compression.Filesystem";
[IO.Compression.Zipfile]::ExtractToDirectory("zola.zip", ".");
displayName: Install Zola
# The check is failing spuriously on Azure Pipelines too often right now (2020 Apr).
# - pwsh: |
# .\zola.exe check
# displayName: Check site
# The "echo" gets past a Zola confirmation to blow away the output directory:
- pwsh: |
echo y |.\zola.exe build -o $(build.artifactStagingDirectory)
displayName: Build site
- task: PublishPipelineArtifact@0
displayName: Publish site as artifact
inputs:
artifactName: static-site
targetPath: $(Build.ArtifactStagingDirectory)
- task: AzureFileCopy@3
displayName: Upload to Azure Storage
inputs:
SourcePath: '$(build.artifactStagingDirectory)'
azureSubscription: ${{ parameters.azureServiceConnectionName }}
Destination: 'AzureBlob'
storage: ${{ parameters.storageAccountName }}
ContainerName: ${{ parameters.containerName }}
blobPrefix: ${{ parameters.pubPrefix }}
- task: AzurePowerShell@4
displayName: Purge CDN
condition: and(succeeded(), ne('${{ parameters.cdnProfileName }}', 'skip'))
inputs:
azureSubscription: ${{ parameters.azureServiceConnectionName }}
azurePowerShellVersion: 'LatestVersion'
scriptType: 'inlineScript'
inline: |
Clear-AzCdnEndpointContent `
-ProfileName ${{ parameters.cdnProfileName }} `
-ResourceGroupName ${{ parameters.cdnResourceGroupName }} `
-EndpointName ${{ parameters.cdnEndpointName }} `
-ContentPath @('${{ parameters.cdnPubPrefix }}/*')