How do GitHub Environments and required reviewers work?
IntermediateConceptGitHub Actions
Answer
An environment (such as production) is a named deployment target in repo settings with protection rules: required reviewers, wait timers, deployment branch/tag restrictions, and environment-scoped secrets and variables. A job that sets environment: production pauses until reviewers approve; its environment secrets become available only after approval.
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: production
url: https://app.example.com
steps:
- run: ./deploy.sh
Environments with reviewers on private repos require a paid plan. Restrict the environment to the main branch so a feature branch cannot deploy to it.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate