Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 lines (82 sloc)
3.23 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/"' |