Interview Prep/Git & GitHub/Protection, Hooks and Policy

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 →

  1. Create a GitHub Environment production with required reviewers and a deployment-branch rule limited to main (and v* tags).
  2. Reference it in the workflow: environment: production; the job pauses until approved.
  3. Scope the deploy secrets to that environment only.
  4. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy