Interview Prep/CI/CD/GitHub Actions

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.

All CI/CD questions

More on GitHub Actions