-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
97 lines (82 loc) · 3.23 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
trigger:
- master
pr: none
variables:
# Subscription needs a storage account
azureSubscription: 'AzureDev'
# This needs to have a static website setup with the default container ($web)
clientBlobAccountName: 'mysitecontainer'
# We build on linux to remove any dependancies on windows stuff / can move to GCP or AWS
vmImageName: 'ubuntu-latest'
# A sample url to be consumed from the react app as environment variable
apiDomain: 'http://dummy.restapiexample.com/api/v1/'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildSite
displayName: Build Site
pool:
vmImage: $(vmImageName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'
- script: |
npm ci
npm run build --if-present
displayName: 'npm install, build'
env:
CI: true
REACT_APP_API_DOMAIN: '$(apiDomain)'
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/build/'
Contents: |
$(System.DefaultWorkingDirectory)/build/**/*
TargetFolder: '$(Build.ArtifactStagingDirectory)/output-site'
displayName: 'Copy site files to artifact directory'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/output-site'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId)-Site.zip
replaceExistingArchive: true
- task: PublishPipelineArtifact@0
displayName: 'Publish site pipeline artifacts'
inputs:
artifactName: "$(Build.BuildId)-Site"
targetPath: $(Build.ArtifactStagingDirectory)/$(Build.BuildId)-Site.zip
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploySite
displayName: Deploy Site Production
environment: 'production'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@1
displayName: 'Download Pipeline Artifacts'
inputs:
artifactName: "$(Build.BuildId)-Site"
buildType: 'current'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/$(Build.BuildId)-Site.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/unzip/$(Build.BuildId)-Site'
cleanDestinationFolder: true
- task: AzureCLI@2
inputs:
azureSubscription: '$(azureSubscription)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'az storage blob upload-batch -d "\$web" --account-name "$(clientBlobAccountName)" -s "$(System.DefaultWorkingDirectory)/unzip/$(Build.BuildId)-Site/"'