A developer pushed directly to main and it went to production without review. How do you stop that?

BeginnerScenarioSecurity incidents
Answer

Situation read → The process allowed it, so fix the guardrail. Talk to the developer, but don't blame them.

What I'd do →

  1. Turn on a branch ruleset (or branch protection) for main: require a PR, at least one approval, passing status checks, and no bypass for admins.
gh api -X PUT repos/acme/api/branches/main/protection --input protection.json
  1. Add CODEOWNERS so changes to sensitive paths (infra, pipelines) need the right team's review.
  2. Make the deploy job only run from merged PRs, and put production behind a protected environment.
  3. Apply it org-wide with rulesets so new repos are covered automatically.
  4. Review the change that went out, and revert it if needed.

Why → Organisation rulesets make the safe path the default for every repo.

Interview tip → Mention "include administrators"; protection that admins can bypass is often how this happens.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents