07 · Make the gate required
Until now the gate's verdict was advice: a red gate showed on the pull request, and GitHub still let you merge. One flag makes it a required check, so a red gate disables the merge button for everyone.
You will learn
- What a required status check is
- The difference between blocking and the rung
- How to watch a required gate block a merge, and clear it
Why now, and not on day one
A required gate on day one would have blocked your first pull request for reasons nobody on the team had seen yet: a checklist, an ADR job, a dependency review that needed a licence. A team blocked by a check it does not understand learns to get around it, and an admin bypass becomes routine.
You have now seen every job go red and turned each one green: the checklist in step 01, the policy in steps 02 and 03, the ADR in step 05, the security floor in step 06. Blocking is no longer a surprise. It is the same checks, with the merge button tied to them.
New term Required status check
A GitHub branch rule that names a check which must pass before a pull request can merge. While it is red or still running, the merge button is disabled. Here the check is redline-gate / gate, and nobody is on the bypass list, admins included.
Let Redline do it this time
In step 01 you committed, opened the pull request and set things up by hand, so you know what each part is. This time init does all of it in one run. Before you run it, here is what it will do:
- Record
"blockingGate": truein.redline.json, commit it on a branch calledredline/onboard, push it and open the pull request. You stay onmain. - Apply a branch ruleset called
Redlinetomain: no deletion, no force-push, changes through a pull request, review threads resolved, a Copilot review requested on every pull request where your plan includes Copilot, andredline-gate / gaterequired. - Switch on the GitHub settings step 01 left for later: secret scanning, push protection and Dependabot alerts.
$ pnpm redline init --blocking Repository settings … in place ✓ already labels label "no-adr" already exists ✓ applied secret-scanning secret scanning ✓ applied merge-policy branch ruleset … Pull request https://github.com/<you>/my-redline-demo/pull/<n>
$ npx redlinegate init --blocking Repository settings … in place ✓ already labels label "no-adr" already exists ✓ applied secret-scanning secret scanning ✓ applied merge-policy branch ruleset … Pull request https://github.com/<you>/my-redline-demo/pull/<n>
$ yarn redline init --blocking Repository settings … in place ✓ already labels label "no-adr" already exists ✓ applied secret-scanning secret scanning ✓ applied merge-policy branch ruleset … Pull request https://github.com/<you>/my-redline-demo/pull/<n>
$ bun run redline init --blocking Repository settings … in place ✓ already labels label "no-adr" already exists ✓ applied secret-scanning secret scanning ✓ applied merge-policy branch ruleset … Pull request https://github.com/<you>/my-redline-demo/pull/<n>
merge-policy is the change that matters. Because .redline.json records blockingGate, a later plain init keeps the gate blocking instead of quietly undoing it.
The ruleset is live as soon as init applies it, so the pull request it just opened is the first one held to it. Watch it, and merge it when it is green:
$ gh pr checks redline/onboard --watch $ gh pr merge redline/onboard --squash $ git pull
Blocking is not the rung
Two separate settings, easy to mix up:
| Setting | Decides | Now |
|---|---|---|
--blocking | whether a red gate stops the merge | on |
--rung | which failures turn the gate red | observe: only the security floor |
So right now only dependency review and the secret scan can stop a merge. Step 02's broken rules would still leave the gate green. Step 09 is about raising the rung.
Watch it block
Open a throwaway pull request that brings back step 06's vulnerable lodash. It exists only to be blocked, and you close it at the end without merging.
$ git checkout -b try/blocked $ pnpm add [email protected] --save-exact $ git commit -am "chore(deps): pin lodash 4.17.20 to see the gate block" $ git push -u origin try/blocked $ gh pr create --title "Do not merge: see the required gate block" --body-file .github/pull_request_template.md $ gh pr checks --watch $ gh pr view --json mergeStateStatus {"mergeStateStatus":"BLOCKED"}
Open it in the browser with gh pr view --web: the merge button is disabled, with redline-gate / gate named underneath.
Private repository The merge button stays enabled
If you handed dependency checks to Dependabot in step 01, dependency review does not run, the gate stays green, and this pull request can merge. That is step 01's trade-off again, in the merge button this time. Secret scanning and push protection are also reported as unavailable by init rather than failing the run.
$ git revert --no-edit HEAD $ git push $ gh pr checks --watch $ gh pr view --json mergeStateStatus {"mergeStateStatus":"CLEAN"}
Fixed, it could merge. It changes nothing, so close it instead, and go back to main:
$ gh pr close $ git checkout main
On GitHub: Settings → Rules → Rulesets → Redline. Or ask GitHub which checks main requires. gh fills in {owner} and {repo} from the repository you are in:
$ gh api 'repos/{owner}/{repo}/rules/branches/main' --jq '.[] | select(.type=="required_status_checks") | .parameters.required_status_checks' [{"context":"redline-gate / gate"}]
A vendored gate can be edited by the pull request it judges. With --gate-source local, a pull request runs the gate file on its own branch, so a change to .github/workflows/redline-gate.yml could weaken the check. A real team closes that gap with the organisation's gate (--gate-source org), or by requiring an owner's review on .github/workflows/ with --with review-ownership --review-owners <team>. init warns about this on every run.
Check your understanding
The gate is now required, at observe. A pull request breaks two BLOCKER rules and nothing else. Can it merge?