Write a GitHub Actions deploy job that requires approval for production using environments.
BeginnerHands-onWrite-a-pipeline tasks
Answer
jobs:
deploy-staging:
runs-on: ubuntu-latest
environment: staging
steps:
- run: ./deploy.sh staging
deploy-prod:
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: production
url: https://app.example.com
steps:
- run: ./deploy.sh production
Key trick → Required reviewers, wait timers and branch restrictions are configured on the production environment in repo settings. The job pauses until someone approves, and environment-scoped secrets are only released then.
More on Write-a-pipeline tasks
Write a GitHub Actions workflow that runs tests on every PR and push to main.BeginnerWrite a workflow that builds a Docker image and pushes it to ECR using OIDC (no access keys).IntermediateWrite a matrix job that tests on Python 3.10, 3.11 and 3.12 on Linux and Windows.BeginnerWrite a declarative Jenkinsfile with build, test, Docker push and a manual approval before prod.AdvancedWrite a reusable workflow and call it from another repo.IntermediateWrite a workflow that only runs the backend job when files under `backend/` change.Intermediate