-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-deploy.yml
More file actions
101 lines (84 loc) · 3.24 KB
/
react-deploy.yml
File metadata and controls
101 lines (84 loc) · 3.24 KB
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
parameters:
- name: siteName
type: string
- name: projectName
type: string
default: '$(System.TeamProject)'
- name: azureLocation
type: string
- name: azureConnection
type: string
- name: targetEnvironment
type: string
values:
- dev
- prod
- qa
default: dev
- name: purgeCDN
type: boolean
default: false
- name: provision
type: boolean
default: false
stages:
- stage: ${{ format('DeploySaticSite_{0}', upper(parameters.targetEnvironment)) }}
variables:
${{ if eq(parameters.targetEnvironment, 'prod') }}:
prefix: ''
${{ if ne(parameters.targetEnvironment, 'prod') }}:
prefix: ${{ parameters.targetEnvironment }}
storageName: ${{ lower(replace(parameters.siteName, '-', '')) }}
Azure.Location: ${{ parameters.azureLocation }}
Azure.ResourceGroup: ${{ format('{0}-{1}', variables.prefix, parameters.projectName) }}
Azure.Storage.Account: ${{ format('{0}{1}', variables.prefix, variables.storageName) }}
jobs:
- deployment: deployStatisSiteJob
displayName: Provision and deploy to BLOB storage
environment: ${{ format('{0}-{1}', 'frontend', parameters.targetEnvironment) }}
strategy:
runOnce:
deploy:
steps:
- checkout: templates
path: templates
- pwsh: |
dir env:AZURE*
displayName: Show deploy parameters
- task: CopyFiles@2
displayName: Add repository custom scripts
inputs:
sourceFolder: $(Pipeline.Workspace)/drop
contents: 'deploy/**'
targetFolder: $(Pipeline.Workspace)/templates
overwrite: true
- task: AzureCLI@2
displayName: Provisioning Azure Resources
inputs:
azureSubscription: ${{ parameters.azureConnection }}
scriptType: pscore
scriptLocation: scriptPath
scriptPath: '$(Pipeline.Workspace)/templates/deploy/static-website.ps1'
condition: and( succeeded(), eq(${{ parameters.provision }}, true) )
- task: AzureCLI@2
displayName: Delete current website files
inputs:
azureSubscription: ${{ parameters.azureConnection }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: az storage blob delete-batch --source '$web' --auth-mode login
- task: AzureCLI@2
displayName: Copy website files to storage
inputs:
azureSubscription: ${{ parameters.azureConnection }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: az storage blob upload-batch --source $(Pipeline.Workspace)/drop/build/ --destination '$web' --auth-mode login
- task: AzureCLI@2
displayName: Purge CDN cache
inputs:
azureSubscription: ${{ parameters.azureConnection }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: az cdn endpoint purge -n $(Azure.Storage.Account) --profile-name $(Azure.Storage.Account)-cdn --content-paths '/*'
condition: and( succeeded(), eq(${{ parameters.purgeCDN }}, true) )