How to Require Status Checks with Branch Protection
Required status checks live in branch protection and block a merge; a badge only displays a result and enforces nothing.
Add a branch protection rule that lists the checks that must pass. The check name is the job name reported to the commit. A badge on the README shows status but has no effect on merges.
Steps
- Open Settings to Branches and add a rule for
main. - Enable "Require status checks to pass before merging".
- Select the check by its job name (it appears after it has run once).
The job whose name becomes the check
.github/workflows/ci.yml
jobs:
build-and-test:
name: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm testBadge vs check
- A badge is a read-only image; anyone can see it but it never blocks anything.
- A required status check is enforcement configured in branch protection, keyed on the check name.
- A green badge with a broken required check still blocks the merge, and vice versa.
Gotchas
- A check must run at least once before it appears in the selection list.
- Renaming a job changes the check name and silently drops it from the required list.
Related guides
How to Create a Commit Status from CI with the Status APICreate a commit status from CI using the GitHub statuses API, posting a state, context, and target URL agains…
How to Choose Between Check Runs and Commit StatusesUnderstand the difference between GitHub check runs and commit statuses, and create a rich check run with the…
How to Add a GitHub Actions Workflow Status BadgeAdd a GitHub Actions workflow status badge to your README by linking the built-in badge.svg endpoint for a sp…