Git, CI/CD & GitOpsXXX · Pull Requests and Merge RequestsApprovals
Approvals and required reviewers — the gate, CODEOWNERS, and the audit
What you'll learn
- Explain the approval count, dismissal rules, and stale-review rules
- Read a CODEOWNERS file and predict which reviewers are required for a given path
- Identify the bypass actors and what they leave in the audit
- Trace the approval audit from a merged commit back to the reviewer
Prerequisites
Verified against Git 2.55.x teaching target; 2.40+ minimum · GitHub Actions continuous service; Aug 2026 documentation baseline · Argo CD v3.5.x teaching target; v3.0+ minimum · Flux v2.9.x · Sigstore Cosign v3.1.x · SLSA v1.2 · OCI Distribution Specification v1.1 · Git LFS v3.7.1 · Kubernetes (cross-course target) 1.36.x
An approval is a reviewer’s assertion that they have read the change and consider it safe to merge. The forge tracks approvals per PR, attributes each to a user and a timestamp, and uses the count plus CODEOWNERS coverage to decide whether the merge button is enabled. The approval is the audit answer to “who said this was OK?”; the bypass is the answer to “who decided the rule did not apply?”.
The approval gate
A protected branch declares how many approvals a PR needs and from whom. Infrastructure teams typically require two approvals, one from a CODEOWNER of the changed paths, and one from someone other than the PR author.
gh pr review 123 --approve
gh pr review 123 --request-changes
gh pr review 123 --comment
An approval is not permanent. If new commits are pushed after the approval, most forges dismiss the stale approval — the reviewer approved a version that no longer exists.
flowchart LR
A["commit a"] --> B["commit b"]
B --> C["commit c"]
C --> D["commit d"]
P["approval on a..c"] -. "dismissed after push of d" .-> D
P2["new approval on a..d"] --> D
CODEOWNERS
CODEOWNERS is a file in the repository that maps paths to owners. When a PR changes a path, the forge identifies the owners and requires an approval from each group whose path matches.
# .github/CODEOWNERS
/iam/ @security-team
/network/ @network-team
/terraform/modules/vpc/ @network-team @platform-team
/ @platform-team
The file is read top-to-bottom and the last matching pattern wins. A path can require multiple owners. CODEOWNERS scales review to a team: without it, every PR bottlenecks through the same handful of reviewers; with it, the load distributes.
Bypass actors and what they leave behind
There are three categories of bypass actors:
- Administrators — admin role can dismiss reviews, push to protected branches, and merge without the required count.
- Break-glass identities — a separate bot account used for incident response, logged separately from normal admin activity.
- Repository rules with exceptions — time windows or path-based exemptions.
Every bypass leaves a record — actor, timestamp, PR, and (ideally) a reason field.
Production discipline
- Two approvals for production changes. One is a rubber stamp; two is a conversation.
- CODEOWNERS for every changed path. A PR touching
/iam/without the security team is a bug. - Author cannot self-approve. The merge button must require an approver other than the author.
- Stale approvals are dismissed. A re-pushed PR requires a new approval.
- Bypass actors are configured, not improvised. Break-glass identity with reason field.
Cross-course references
- GitOps with Argo CD - Part VI (Policy): CODEOWNERS-style enforcement at the cluster level.
- CI/CD Pipeline Patterns - Part VIII (ApprovalGates): approval gates in deployment pipelines.
- Terraform for Production Sysadmins - Part XI (PRWorkflows): CODEOWNERS patterns for Terraform modules.
Quiz
Knowledge check · 4 questions
Q1. A PR is approved by reviewer A against a 200-line diff. The author then pushes three more commits that add 800 lines. Stale review dismissal is enabled. What is the state of the approval?
Q2. CODEOWNERS is stored as a tree object in the Git repository and is therefore portable across forges without configuration.
Q3. Name the three categories of bypass actors that can merge a PR without satisfying the standard approval rules.
Q4. Reconstruct the approval audit for a production incident and identify the missing approver.
A misconfigured security group rule was merged to production last Tuesday. The PR was approved by the PR author alone, then merged by an admin who dismissed the only other reviewer's request-changes. The auditor asks: who approved this change, and was the security team involved?
Passing score: 75%. Answers are checked in this browser.