Prevent exposed secrets from reaching protected branches by requiring contributors to resolve secret scanning alerts before merging.
Note
The rule to require secret scanning alerts to be resolved before merging is in public preview and subject to change.
The Require secret scanning alerts are resolved rule is available for rulesets that target branches in repositories. You can use the rule to block a pull request from merging when either of these conditions applies:
The rule supports provider, custom, and generic patterns. It does not support AI-detected secrets.
The repositories that you want to protect must have:
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

In the left sidebar, under "Code, planning, and automation", click Rulesets, then click Rulesets.
Click New ruleset.
Click New branch ruleset.
Under "Ruleset name," type a name for the ruleset.
Optionally, to change the default enforcement status, click Disabled and select an enforcement status.
To target branches or tags, in the "Target branches" or "Target tags" section, select Add a target, then select how you want to include or exclude branches or tags. You can use fnmatch syntax to include or exclude branches or tags based on a pattern. For more information, see Using fnmatch syntax.
You can add multiple targeting criteria to the same ruleset. For example, you could include the default branch, include any branches matching the pattern *feature*, and then specifically exclude a branch matching the pattern not-a-feature.
For information about configuring bypass permissions and other ruleset settings, see Creating rulesets for a repository.
In the upper-right corner of GitHub, click your profile picture, then click Organizations.
Select an organization by clicking on it.
Under your organization name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

In the sidebar, under "Code, planning, and automation", click Repository, then click Rulesets.
Click New ruleset.
Click New branch ruleset.
Under "Ruleset name," type a name for the ruleset.
Optionally, to change the default enforcement status, click Disabled and select an enforcement status.
Under "Target repositories", choose the repositories that the ruleset will apply to.
To target branches or tags, in the "Target branches" or "Target tags" section, select Add a target, then select how you want to include or exclude branches or tags. You can use fnmatch syntax to include or exclude branches or tags based on a pattern. For more information, see Using fnmatch syntax.
You can add multiple targeting criteria to the same ruleset. For example, you could include the default branch, include any branches matching the pattern *feature*, and then specifically exclude a branch matching the pattern not-a-feature.
For information about configuring bypass permissions and other ruleset settings, see Creating rulesets for repositories in your organization.
When this rule blocks a pull request because of open alerts, you must resolve each alert that matches the secret types selected in the ruleset. See Resolving alerts from secret scanning.