Safeguard
Developer Tools•

How do you make a security scan a required check before merge?

Run the scan on every pull request, name the job, then mark it as a required status check in branch protection. Steps, pitfalls, and what skipped means.

Safeguard Security Team
3 min read

Run the scan as a named job on every pull request, then open your branch protection rule and require that job's status check before merging. Test it with a deliberately failing change. Also confirm the job cannot be skipped, because on GitHub a skipped check counts as passing.

What "required" means

A scan that runs but is not required is advice. Anyone with merge rights can ignore a red result. A required check turns the result into a condition of merging.

GitHub's documentation lists the relevant protection settings, including requiring pull request reviews, requiring status checks, requiring a merge queue, and a setting that blocks bypassing the rules. It says required status checks must have a successful, skipped, or neutral status before collaborators can change a protected branch.

Steps

  1. Create a workflow that runs the scan on the pull request event. Give the job a stable, specific name such as security-scan.
  2. Open the repository settings and add a branch protection rule for your main branch.
  3. Enable the option that requires status checks before merging.
  4. Search for your job name and add it to the required list.
  5. Open a test pull request with a known failing condition and confirm the merge button is blocked.
  6. Open a second test pull request that changes only documentation and confirm the check still reports a result.

Step 6 matters. If your workflow uses path filters and the scan does not run for some changes, a required check can hang as pending or, in other setups, be treated as skipped.

Common pitfalls

PitfallEffectFix
Job renamed laterRequired name no longer matches, check never reportsKeep job names stable and update the rule when renaming
Path filters skip the jobMerge blocked or check bypassedRun the job always, and filter inside it
Admins can bypassRule does not bind everyoneEnable the setting that prevents bypass where your policy requires it
Scan errors exit zeroA broken scanner looks like a passFail the job on tool errors
Forks lack secretsScan cannot reach its dataDesign a safe fork path, see the fork post linked below

Skipped is not the same as passed

The documented behavior is that skipped satisfies a required check. That is convenient for conditional workflows and risky for security. Review any condition on the job, such as an if expression on the actor or the changed files, and ask whether it could cause the scan to be skipped on a change that matters.

Related reading

Pull requests from forks need special care. See scanning pull requests from forks without exposing secrets.

Where Safeguard fits

Safeguard provides policies and gates that report a pass or fail status on pull requests, which you can then mark as required in branch protection. You can see the kind of results it returns with the free scan at https://gold.safeguard.sh/scan.

Quick check

Does a required check stop administrators too?

Only if the rule is set to apply to them. GitHub lists a setting that prevents bypassing the protection settings. Decide deliberately whether admins are included.

What if the scan is slow?

Scope the pull request scan to changes and move full scans to a scheduled job. A required check that takes too long gets disabled by frustrated teams.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.