Deploy to staging, test, then promote to production with approval.
image: node:20
stages:
- deploy-staging
- test
- deploy-production
deploy-staging:
stage: deploy-staging
script:
- npm install
- npx zuplo deploy --api-key "$ZUPLO_API_KEY" --environment staging 2>&1 |
tee ./DEPLOYMENT_STDOUT
- echo "STAGING_URL=$(grep -oP 'Deployed to \K(https://[^ ]+)'
./DEPLOYMENT_STDOUT)" >> staging.env
artifacts:
reports:
dotenv: staging.env
only:
- main
test-staging:
stage: test
needs:
- deploy-staging
script:
- npm install
- npx zuplo test --endpoint "$STAGING_URL"
only:
- main
deploy-production:
stage: deploy-production
needs:
- test-staging
script:
- npm install
- npx zuplo deploy --api-key "$ZUPLO_API_KEY" --environment production
only:
- main
when: manual
environment:
name: production
Setting Up Approval
The when: manual setting requires someone to click "Play" in the GitLab UI to
trigger production deployment.
For more control, use
Protected Environments:
- Go to Settings > CI/CD > Protected environments
- Add
production as a protected environment
- Specify which users or groups can deploy
Last modified on