// answer

Blocking Noncompliant Dependencies on GitHub

Short answer

Yes. Protect the branch, add a dependency review or policy check, and require that status check before merge. GitHub then blocks the pull request until the check passes.

The harder question is who you do it with: Find collaborators

Can I block noncompliant open source dependencies from merging on GitHub

Yes. GitHub can block a pull request from merging if you protect the target branch and require a check that fails when a dependency breaks your policy. The usual pattern is branch protection plus a dependency review workflow, then mark that workflow as required before merge. GitHub documents that required status checks must pass before collaborators can merge into a protected branch.

The part people get wrong is this: branch protection by itself does not understand your license or compliance rules. Branch protection only enforces that a status check, review, or other rule passes. The compliance logic has to live in a status check you control, such as a GitHub Actions workflow that inspects dependency changes, SBOM data, or a policy file in the repository. GitHub’s dependency review action is built for detecting vulnerable dependency additions in pull requests, and GitHub allows required status checks to gate the merge.

A practical setup looks like this. Put the check on the default branch protection rule or on a ruleset, require pull request reviews, and require the dependency policy check before merging. Then make the policy check fail whenever a pull request adds a dependency that violates your standard, for example an unapproved license, a package from a blocked source, or a dependency with a known vulnerability that your policy treats as noncompliant. GitHub’s docs say required status checks can be tied to a specific app, which matters if you want to trust only one workflow source.

The inconvenient part is that GitHub does not read your intent. If the workflow does not run, is misnamed, or is not selected as required, the merge can still go through. GitHub also notes that some dependencies may not be parsed by the review tooling, so you still need to review manifest and lockfile changes when the output looks incomplete. In other words, the gate is only as strong as the check behind it.

If your goal is only vulnerability blocking, the dependency review action is the most direct built-in option. GitHub says it scans pull requests for dependency changes and raises an error if new dependencies have known vulnerabilities. If your goal is broader compliance, you need a custom policy layer on top of that, because vulnerability detection is not the same thing as license approval, vendor approval, or export-control review. Those are separate rules, and GitHub does not collapse them into one switch.

You can also combine more than one control. A common pattern is dependency review for security, code owners for human approval, and a custom job that checks an allowlist or denylist of licenses. GitHub’s branch protection and ruleset docs both support requiring multiple checks and multiple approvals. That combination is stronger than a single binary pass or fail, because it gives you one gate for automated policy and another gate for human judgment.

The failure mode to plan for is bypass. GitHub docs describe options like allowing or disallowing bypass of protection settings, and they note that people with write access can influence status checks unless you bind the requirement to a specific app. If you want the policy to actually hold, restrict who can bypass the rule, require the exact check source you trust, and keep direct pushes off the protected branch.

A simple example is a repository that must not merge GPL-incompatible code. Your workflow can inspect dependency deltas in a pull request, compare new packages against a license allowlist, and fail if a package is missing approval. You then mark that workflow as required on the main branch. A developer can still open the pull request, but they cannot merge until the check passes, which is the point of the gate. That is cleaner than trying to police compliance after the code is already on main.

If you want to enforce this at scale, use a ruleset rather than only an old-style branch protection rule. GitHub’s ruleset docs expose the same core concept, required status checks must pass before merging, and they let you apply policy across branches or tags. That is useful when the merge target is not just main, or when you want one policy file to govern more than one repo path.

If you are building this on DevConnect, the same principle applies on your own property: automate the check, not the social behavior. DevConnect is built for owned workflows, and GitHub is where you can enforce the merge gate. For the platform context, see https://devconnectplatform.com. The blocking mechanism still has to be a required status check or review rule in GitHub, not a manual promise from a contributor.

The short answer is yes, and the exact mechanism is required status checks on a protected branch or ruleset. The longer answer is that you need a real policy check, not just branch protection, and you need to keep the check source, bypass settings, and dependency parsing under control if you want the block to hold.

What to set up

  1. Protect the target branch or use a ruleset.
  2. Add a dependency policy workflow that inspects pull request dependency changes.
  3. Require that workflow as a status check before merging.
  4. Bind the required check to the exact app or workflow source you trust.
  5. Turn off bypass if you want the rule to stay real.

What this does not solve

It does not magically classify every dependency on its own. It does not replace legal review. It does not catch every package if your tooling cannot parse the manifest or lockfile. It does not stop someone from opening the pull request in the first place. It only stops the merge until your required checks say the change is acceptable.

Concrete way teams use it

A team keeps a license allowlist in the repo, runs a workflow on every pull request, and fails the workflow if a new dependency is not on the list. They require that workflow on main, plus one human approval. A contributor can still propose a change with a noncompliant package, but GitHub blocks the merge request as soon as the required check fails. That is the cleanest way to enforce dependency policy on GitHub without relying on memory or discipline.

FAQ

Can I block merges on license violations, not just vulnerabilities? Yes, if you build a custom check that evaluates license policy and make that check required before merge. GitHub’s built-in dependency review focuses on vulnerable dependency changes, so license enforcement needs your own policy logic.

Can I require approval from a specific GitHub App? Yes. GitHub says you can select an expected source for status updates, which is how you keep a required check tied to one trusted app rather than any write-capable integration.

Will this stop every bad dependency automatically? No. GitHub warns that some dependencies may not be parsed by dependency review, so you still need to inspect manifest and lockfile changes and keep your policy check current.

Do I need branch protection, or is a ruleset enough? Either can enforce required status checks. Rulesets are the newer policy layer, while branch protection still works for the same core gate. The choice is mostly about how you want to manage and scope the rule.

Can admins bypass it? GitHub offers bypass-related settings, so the answer depends on how you configure the rule. If you want a hard gate, disable bypass and limit who can change the policy.

Frequently asked questions

Can I block merges on license violations, not just vulnerabilities

Yes, if you build a custom check that evaluates license policy and make that check required before merge. GitHub’s built-in dependency review focuses on vulnerable dependency changes, so license enforcement needs your own policy logic.

Can I require approval from a specific GitHub App

Yes. GitHub says you can select an expected source for status updates, which is how you keep a required check tied to one trusted app rather than any write-capable integration.

Will this stop every bad dependency automatically

No. GitHub warns that some dependencies may not be parsed by dependency review, so you still need to inspect manifest and lockfile changes and keep your policy check current.

Do I need branch protection, or is a ruleset enough

Either can enforce required status checks. Rulesets are the newer policy layer, while branch protection still works for the same core gate. The choice is mostly about how you want to manage and scope the rule.

Can admins bypass it

GitHub offers bypass-related settings, so the answer depends on how you configure the rule. If you want a hard gate, disable bypass and limit who can change the policy.

Know someone stuck on this? Send them the answer.

Sources

Every link here was fetched and confirmed to resolve before this page went live.

More on this topic: Collaborators

Related questions

Not the question you had?

Ask it. Every source gets fetched and checked before anything goes up, so it takes a day or two, and questions that cannot be answered honestly do not get a page at all.

No account, no email address needed.

Looking for someone to build it with?

People on DevConnect post what they are building and what they are missing. You can browse projects, or say what you want to work on and let people come to you.