Production deploys should require a manual approval and only from reviewed code.
AdvancedScenarioProtection, Hooks and Policy
Answer
Situation read → Branch protection controls code; environment protection controls deployment.
What I'd do →
- Create a GitHub Environment
productionwith required reviewers and a deployment-branch rule limited tomain(andv*tags). - Reference it in the workflow:
environment: production; the job pauses until approved. - Scope the deploy secrets to that environment only.
- Enable "Prevent self-review" so the person who triggered it cannot approve.
Why → Secrets stored in an environment are released only after rules pass, so a rogue branch cannot reach them.
Interview tip → Combine OIDC federation with environments so there are no long-lived cloud keys.
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerClassic branch protection or repository rulesets: which do you use?IntermediateA required status check never reports and the PR is stuck as "Expected — Waiting for status".IntermediateProduction is down and the fix needs to merge now, but approvals are required.IntermediateYou want to stop developers from committing obvious mistakes like debug prints, trailing whitespace or secrets.BeginnerHooks in `.git/hooks` are not shared with the team. How do you distribute them?Intermediate