Git & GitHub Interview Question #102
What are environment protection rules in GitHub Actions?
Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced
Quick Interview Answer
Environment protection rules add controls around jobs that target a GitHub environment. Depending on repository capabilities and configuration, deployment can be gated by reviewers, waiting periods, branch or tag restrictions, or other protection mechanisms.
Detailed Explanation
Environment protection rules add controls around jobs that target a GitHub environment. Depending on repository capabilities and configuration, deployment can be gated by reviewers, waiting periods, branch or tag restrictions, or other protection mechanisms.
These controls are useful when CI may run automatically but production deployment should require stronger governance. The workflow and repository settings should work together rather than storing approval logic only in scripts.
Code Example
jobs:
deploy:
environment: production
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh
# Approval/protection is configured for the
# production environment on GitHub.