Git Hooks vs GitHub Actions: Which One Actually Enforces Your Checks?

Date:

Your CI shows a red ✗, and the merge goes through anyway. On a small team’s private repos that is normal, and it means the governance workflows were never enforcing anything. A running-out bill is often what exposes it; the more useful question is where those guards should run instead.

The short answer: governance workflows such as a shared-guards runner, a pull-request base check, and their kin are often enforcement theater. On a plan without required status checks they can render an advisory ✗ but never block a merge, so they enforce nothing; and because a GitHub Actions workflow can’t deploy globally, each one silently protects only the repo it was born in, and the same bug it was meant to stop recurs elsewhere. Cost doesn’t break them; cost exposes that they were never load-bearing. Their real jobs are two things a metered CI check is the wrong tool for: encoding intent and running the check wherever the mistake is made. Both belong in a globally-deployed git hook, not a per-repo workflow. CI earns its keep on exactly one thing a local hook can’t do (a clean, reproducible environment for a contributor population you don’t control), and until you have that population, the honest amount of governance CI is close to zero.

The billing side is covered in two companion posts, on what CI minutes really cost and on workflows that bill while doing nothing. Strip the billing away and a plainer question is left: what are these guards for? The worked example below is a ten-repo private estate that grew and then retired exactly this kind of CI.

How governance CI accretes, and why it feels right

The example estate is ten private repositories worked by one developer. Over a quarter, governance accreted the way it usually does, each piece a reasonable answer to a real incident:

  • A shared-guards workflow. One canonical set of checks (layer isolation, documentation discipline, naming rules) that every repo should run, wired to clone a private tooling repo and execute them in CI.
  • A pull-request base check. A guard that a PR targets the default branch, written after a stacked PR (one based on a feature branch) got auto-closed and orphaned when its base was deleted on merge.
  • The test workflow. The actual suite, on every push and every pull request.

Each looked like diligence. Together they looked like a governed estate. That appearance is exactly the trap.

Why these workflows can’t do their jobs

Two structural facts, invisible until you look, hollowed the first two out.

On this plan, a check cannot block a merge. Required status checks, the setting that makes a red ✗ stop a merge, are a paid feature; the API refuses to enable them on a private repo without a plan. So every one of these checks was, at best, advice next to the merge button. The shared-guards workflow was worse than advisory: the token it needed to clone the tooling repo was never set in any repo, so its first step was exit 0: a green check that had executed nothing at all.

A check that cannot block a merge is not a gate. It is a decoration that boots a virtual machine.

A workflow can’t deploy itself. A git hook installed through core.hooksPath covers every repo on the machine at once, for free, forever. A GitHub Actions workflow only runs from a file committed inside the repo it guards, so a “universal” workflow guard has no distribution. In the example estate, that guard was written in one repository and copied nowhere, and months later the identical orphaned-PR bug recurred in a second repo that never got the file. The guard wasn’t wrong; it simply wasn’t present where it was needed, and nothing made it present.

What was actually doing the work

The whole time, the real enforcement lived somewhere quieter: a pre-push git hook, deployed globally through core.hooksPath, running the same checks on every push on the one machine that mattered. It blocked (a failing check refused the push), which is more than the advisory CI could ever do. And because it was deployed once to the machine rather than committed per repo, it could not go missing from “a repo that never got the file.” The mechanism that got the least trust, because it wasn’t visible on the pull-request page, was the only one holding the line.

What happens when the minutes run out

When the month’s Actions minutes ran out, the theater became impossible to ignore: every workflow went red on billing, and merges sailed through anyway, because nothing had been gating them. So almost the whole set was retired, recoverably:

  • the shared-guards runner and the base check: removed from the canonical set and every repo, their intent moved into the global pre-push hook (and, for the base rule, a small local lint that reads open pull requests and warns);
  • the test workflow: kept, but recognized for the one thing it uniquely provides.

The estate’s governance did not get weaker. It got honest. The rules that were being enforced locally went on being enforced locally; the rules that were being “enforced” by an advisory ✗ started being enforced for the first time, by a hook that can actually say no.

Governance didn’t get weaker when the workflows were deleted. It got honest.

So what is a governance workflow really for?

Reassembled from the wreckage, each retired workflow had been reaching for one of two things, and metered CI was the wrong instrument for both:

  1. Encoding intent. “PRs target the default branch.” “These layer rules matter.” That’s valuable and worth writing down, but a workflow file is a poor place to write it, because it only speaks when it runs, only in the repo it sits in, and (on this plan) only as a suggestion. Intent belongs somewhere that travels and that acts: a hook that runs everywhere, or plain documentation that a human reads.
  2. Running the check where the mistake is made. The point of a guard is to catch the error at the moment it happens, in every place it can happen. A per-repo workflow does the opposite: it catches it in one place, after the fact, without the power to stop it. “Everywhere, at the moment, with teeth” is the definition of a globally-deployed pre-commit/pre-push hook.

Which leaves the honest, narrow role that is genuinely CI’s alone: a clean, reproducible environment for code from a machine you don’t control. A local hook runs on the author’s box, with the author’s dependencies, against the author’s checkout. The day a second contributor appears (or an outside pull request, or a machine whose hooks you can’t guarantee), that clean-room, can’t-be-skipped property is exactly what CI provides and a hook cannot. Until that day, on a small private estate, the correct amount of governance CI is close to none.

A rule you can borrow

Before you write a guard, ask three questions in order:

  • Is it static and deterministic? (a lint, a naming rule, a unit test) → a git hook, deployed globally. Free, everywhere, with teeth. Never a workflow.
  • Does it need a clean, reproducible environment you can’t trust the author’s machine to provide, or must it run on code from a machine you don’t control? → CI. This is what CI is for.
  • Is it really just intent — a rule people should know? → write it down. A workflow that can’t block is documentation with a server bill; the documentation without the bill is strictly better.
Where should a guard run?Ask in order; most guards never reach the cloud
Static + deterministic?

lint / naming / unit test → git hook (global) blocks, everywhere, free

Needs a clean room?

untrusted machine / reproducible env → GitHub Actions CI

Really just intent?

a rule people should know → write it down

A workflow that can't block a merge is documentation with a server bill — prefer the hook, or the doc.

The trap is answering “should this be governed?” with “add a workflow,” when the useful question is “where should this guard run?” Most of the time the answer was: not in the cloud, and not for a bill.

The question was never “should this be governed?” — it was “where should this guard run?”

The short version

  • The retired workflows were enforcement theater: on a plan without required status checks they could show an advisory ✗ but never block a merge, so they never enforced anything.
  • A workflow can’t deploy globally, so a “universal” guard protected only its home repo, and the bug it targeted recurred where the file never reached.
  • The real enforcement was a globally-deployed pre-push git hook all along. It blocks, and it can’t go missing from a repo.
  • Their real role was intent + running the check where the mistake happens, both of which belong in a git hook (or documentation), not metered CI.
  • CI’s honest, narrow job is the one a hook can’t do: a clean-room run for contributors and machines you don’t control. Below that bar, a small estate needs almost no governance CI.
  • Decision rule: static/deterministic → git hook; needs a clean room or untrusted contributors → CI; pure intent → write it down.

Frequently Asked Questions

If a workflow can’t block anything, is it useless?

Not useless, but rarely worth a per-run cost. Its value is signal (a human notices the ✗) and a record of intent. Both are usually served better by a local hook that actually blocks, or by plain documentation that carries no compute bill. Keep an advisory workflow only when the signal genuinely changes behavior and the cost is negligible.

Does a public repository have the same problem?

No. On GitHub’s free plan, branch protection and required status checks are available for public repositories; the limit applies to private ones. A public repo can make a red check stop the merge, which is also where outside pull requests arrive, so it is the case where CI’s clean-room run earns its place.

Isn’t a local hook easy to bypass with –no-verify?

Yes, and that is the honest limit of a hook: it protects a cooperating developer from mistakes, not a hostile one from intent. For a solo or high-trust small team that is the whole threat model, so a hook is sufficient. Once you need to enforce against someone who might deliberately skip the check, you need a server-side gate (required status checks on CI), which is precisely the paid, contributor-facing case CI was built for.

Share post:

Subscribe

Popular

More like this
Related

WooCommerce Search by SKU or ISBN Finds Nothing? It Never Looks There

A shopper types the SKU from your catalog, or the ISBN printed on the back of a book, and gets "No products were found". The product is right there, and the number is on its page. Search simply never reads that part of the product.

Computer Slow but CPU and Memory Look Normal? Check the Handle Count

Chrome takes a minute to open, or doesn't open at all. Every click waits. You open Task Manager expecting to find the culprit, and it tells you everything is fine. Here is the number that isn't, and the fix that takes two minutes.

Kernel-Power 41 Tells You Your PC Restarted, Not Why

Your PC restarts with no blue screen, and the only clue is a critical event saying it didn't shut down cleanly. Here is how to get from that event to a short list of suspects.

Set Up WordPress SMTP Without a Plugin, Even on a Multisite Network

WordPress mail goes out as wordpress@ your domain, from the web server, and lands in spam. An SMTP plugin fixes that. So do about twenty lines of code, and on a network of sites the code can give every site its own mailbox and its own password.