Deploy to staging, test, then promote to production with approval.
trigger:
- main
pool:
vmImage: ubuntu-latest
stages:
- stage: DeployStaging
displayName: "Deploy to Staging"
jobs:
- job: Deploy
steps:
- task: NodeTool@0
inputs:
versionSpec: "20.x"
- script: npm install
- script: |
set -o pipefail
npx zuplo deploy --api-key $(ZUPLO_API_KEY) --environment staging 2>&1 | tee ./STAGING_STDOUT
STAGING_URL=$(grep -oP 'Deployed to \K(https://[^ ]+)' ./STAGING_STDOUT)
echo "##vso[task.setvariable variable=STAGING_URL;isOutput=true]$STAGING_URL"
name: deployStep
displayName: "Deploy to staging"
- stage: TestStaging
displayName: "Test Staging"
dependsOn: DeployStaging
variables:
STAGING_URL:
$[
stageDependencies.DeployStaging.Deploy.outputs['deployStep.STAGING_URL']
]
jobs:
- job: Test
steps:
- task: NodeTool@0
inputs:
versionSpec: "20.x"
- script: npm install
- script: npx zuplo test --endpoint $(STAGING_URL)
displayName: "Run tests against staging"
- stage: DeployProduction
displayName: "Deploy to Production"
dependsOn: TestStaging
jobs:
- deployment: Deploy
environment: production
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: NodeTool@0
inputs:
versionSpec: "20.x"
- script: npm install
- script:
npx zuplo deploy --api-key $(ZUPLO_API_KEY) --environment
production
displayName: "Deploy to production"
Setting Up Approval
Create an environment with approval checks:
- Go to Pipelines > Environments
- Create an environment named
production
- Add Approvals and checks
- Add required approvers
The pipeline pauses before production deployment until approved.
Last modified on