-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
101 lines (92 loc) · 2.93 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
# Deploy Azure Static Website
#
# Author: Adam Rush
# Blog: https://adamrushuk.github.io
# GitHub: https://github.com/adamrushuk
# Twitter: @adamrushuk
#
# YAML schema reference: https://aka.ms/yaml
trigger:
batch: true
branches:
include:
- master
variables:
system.debug: false
# Main vars
VM_IMAGE: ubuntu-16.04
SERVICE_CONNECTION: arm_sc01
LOCATION_NAME: uksouth
RESOURCE_GROUP_NAME: old-blog-rg
STORAGE_ACCOUNT_NAME: virtuallyimpossiblecouk
CONTENT_RELATIVE_PATH: content
DOMAIN_FQDN: www.virtuallyimpossible.co.uk
PRIMARY_ENDPOINT: DynamicallyAssignedDuringPipelineRun
# DNS vars
DOMAIN_NAME: virtuallyimpossible.co.uk
# DNS_API_KEY: SecretDefinedInPipeline
# DNS_API_SECRET: SecretDefinedInPipeline
stages:
- stage: Deploy
jobs:
- job: Deploy
pool:
vmImage: $(VM_IMAGE)
steps:
- task: AzurePowerShell@4
displayName: "Azure PowerShell Script: Deploy Static Website"
inputs:
azureSubscription: $(SERVICE_CONNECTION)
ScriptPath: scripts/Deploy-StaticWebsite.ps1
ScriptArguments: >
-LocationName $(LOCATION_NAME)
-ResourceGroupName $(RESOURCE_GROUP_NAME)
-StorageAccountName $(STORAGE_ACCOUNT_NAME)
-ContentRelativePath $(CONTENT_RELATIVE_PATH)
-DomainFqdn $(DOMAIN_FQDN)
azurePowerShellVersion: LatestVersion
- task: AzureCLI@1
displayName: "Azure CLI: Upload blob content"
inputs:
azureSubscription: $(SERVICE_CONNECTION)
scriptLocation: 'inlineScript'
inlineScript: >
az storage blob upload-batch
--account-name "$(STORAGE_ACCOUNT_NAME)"
--source "$(CONTENT_RELATIVE_PATH)"
--destination '$web'
- task: PowerShell@2
displayName: "PowerShell Script: Update DNS A Record"
inputs:
targetType: filePath
filePath: scripts/Update-Dns.ps1
arguments: >
-DomainName $(DOMAIN_NAME)
-RecordType "CNAME"
-RecordName "www"
-RecordValue $(PRIMARY_ENDPOINT)
-ApiKey $(DNS_API_KEY)
-ApiSecret $(DNS_API_SECRET)
pwsh: true
- task: PowerShell@2
displayName: "PowerShell Script: Wait for successful Web Request"
inputs:
targetType: filePath
filePath: scripts/Wait-StaticWebsiteCnameReady.ps1
arguments: >
-DomainFqdn $(DOMAIN_FQDN)
-WaitForStatusCode 400
-TimeoutSeconds 240
pwsh: true
# continueOnError: true
- task: AzurePowerShell@4
displayName: "Azure PowerShell Script: Set Custom Domain"
inputs:
azureSubscription: $(SERVICE_CONNECTION)
ScriptPath: scripts/Set-CustomDomain.ps1
ScriptArguments: >
-ResourceGroupName $(RESOURCE_GROUP_NAME)
-StorageAccountName $(STORAGE_ACCOUNT_NAME)
-DomainFqdn $(DOMAIN_FQDN)
azurePowerShellVersion: LatestVersion
# condition: succeededOrFailed()