Why do you use branch protection rules in a CI/CD workflow?
Branch protection rules on the main or production branch enforce quality gates before any code is merged:
- Require pull request reviews (at least 1-2 approvals)
- Require status checks to pass (CI build, tests, linting)
- Require branches to be up to date before merging
- Prevent force pushes and branch deletion
This ensures no untested or unreviewed code ever reaches production, which is the foundation of a trustworthy deployment pipeline.