Who can report a check name#
A required status check is matched by name. GitHub says so in more than one place: "Anyone with write permissions to a repository can set the state for any status check in the repository" (status checks), and "Organization owners and users with push access to a repository can create checks and commit statuses with GitHub's API." Checks come from GitHub Apps, including GitHub Actions. Commit statuses come from "external services and integrations," through the commit statuses API, which accepts a context string that becomes the name.
Both kinds count toward the same requirement. The troubleshooting guide adds one detail that shapes how the problem shows up: "If a check and a commit status have the same name, both must pass when that name is required." Troubleshooting required status checks So a stray successful status does not override a failing real check. It matters when the real check is absent, because then the stray status is the only thing GitHub sees.
The fix is a setting on the requirement itself. In a ruleset, "you can select an app as the expected source of status updates," and "If the status is set by any other person or integration, merging won't be allowed." The app "must be installed in the repository with the statuses:write permission, must have recently submitted a check run, and must be associated with a pre-existing required status check in the ruleset." Available rules for rulesets Branch protection rules offer the same choice when you add a required check (about protected branches). A pull request blocked this way shows: Required status check "build" was not set by the expected GitHub App.
A fictional migration that left an old reporter behind#
Suppose acme/ledger moved its build from a self-hosted CI server to GitHub Actions. The new workflow has a job named build, and the main branch ruleset requires build from "any source." Nobody turned off the old server's webhook, and it still posts a commit status with context build on every push. Since the migration it only lints the README, so it always reports success.
For months this is harmless, because both reporters run on every pull request and both must pass. Then a pull request restructures .github/workflows/ci.yml and, in the process, drops the build job. The Actions build check never appears on that pull request. The old server's build status does, it is green, and the requirement is met. The pull request merges without a compile.
Pinning build to GitHub Actions turns that into a block. The old server's status no longer counts, the Actions check is missing, and the merge box waits for the right reporter. The team notices the missing check, and the stale webhook, on the same day.
Configure the pin#
In the UI, edit the ruleset's Require status checks to pass before merging rule and choose the app next to each check instead of "any source." Through the REST API, each entry in required_status_checks takes an optional integration_id, documented as "The optional integration ID that this status check must originate from" (create a repository ruleset).
{
"name": "main: required checks",
"target": "branch",
"enforcement": "active",
"conditions": {
"ref_name": {
"include": ["~DEFAULT_BRANCH"],
"exclude": []
}
},
"rules": [
{
"type": "required_status_checks",
"parameters": {
"strict_required_status_checks_policy": false,
"required_status_checks": [
{ "context": "build", "integration_id": 123456 }
]
}
}
]
}
Replace 123456 with the app's ID. You can read it from a recent check run: the list check runs for a Git reference endpoint returns each run with an app object that has an id.
Do this for every required check, not only the one you are worried about. A requirement left on "any source" is the one a stray reporter will satisfy.
What the pin does not catch#
The pin checks who reported, not what ran. If a pull request can edit the workflow, it can make the GitHub Actions job named build do nothing, and the pinned app will report that success faithfully. Protecting .github/workflows/ with code owners is the control for that case (a pull request that edits its own workflow).
It also does not separate two jobs with the same name inside GitHub Actions, since both come from the same app. GitHub warns about this directly: "make sure that job names are unique across all workflows. Using the same job name in multiple workflows can cause ambiguous status check results and block pull requests from being merged." About protected branches
The docs describe the expected source only as a GitHub App. A CI system that posts statuses with a person's token has no app to pin, so its checks stay on "any source" until it reports through an app.
What it costs#
Pinning ties the rule to a reporter. When you change CI providers, or move a check from one app to another, the old pin blocks every pull request until you update the ruleset, and the new app must have submitted a check run recently before you can select it. Plan the switch the same way as a renamed check: run both, re-pin, then remove the old reporter.
The decision#
Pin every required check to the app that produces it as soon as the check is stable. Keep "any source" only for a reporter that cannot run as an app, and treat that requirement as weaker when you reason about what a green merge box proves. When the merge box shows a required check from an unexpected reporter, find and remove that reporter instead of re-pinning to it.