CI — prek hooks
Runs the calling repository's prek (pre-commit) hooks in CI: prek run --all-files.
Local hooks only protect machines that ran prek install. A Renovate PR, an edit made through the GitHub web UI, a fresh clone that skipped the setup or a --no-verify push all bypass them. This workflow re-runs the same config server-side, turning the hooks into a gate instead of a convenience.
Usage
yaml
jobs:
prek:
uses: KevinDeBenedetti/github-workflows/.github/workflows/ci-prek.yml@v0.57.0 # x-release-please-version
with:
runner: '"ubuntu-26.04"'Run a single hook instead of the whole suite:
yaml
with:
extra-args: renovate-config-validator --all-filesInputs
| Input | Type | Default | Description |
|---|---|---|---|
extra-args | string | --all-files | Arguments passed to prek run — e.g. --all-files or a hook id |
working-directory | string | . | Directory holding the prek config |
prek-version | string | pinned (Renovate) | prek release to install, without the leading v (or latest) |
cache | boolean | true | Cache the prek hook environments between runs, in the GitHub cache |
timeout-minutes | number | 20 | Minutes before the job is cancelled |
runner | string | '"ubuntu-26.04"' | Runner labels as JSON — '"ubuntu-26.04"' or a label array |
Steps
- Checkout
- Verify a prek config exists (
prek.toml,.prek.toml,.pre-commit-config.yamlor.pre-commit-config.yml) — a missing config is an error, not a skip - Run
j178/prek-action(SHA-pinned), which installs prek and runsprek run --show-diff-on-failure --color=always <extra-args>
Notes
- Thin wrapper by design. A reusable workflow checks out the calling repo, so this runs that repo's own
prek.toml— one hook definition backing both CI and pre-commit, with nothing to keep in sync twice. - Expect overlap. A repo that already has dedicated jobs for shellcheck, actionlint or Gitleaks will run those tools twice — once here through the hooks, once in the dedicated job. That is usually acceptable (the hooks are cached and fast), but
extra-argsaccepts a hook id when you would rather run only what the other jobs do not cover. - Hooks need network access. prek downloads hook repositories and, depending on the hook
language, a managed toolchain (Node, Python, Go…). A runner behind a strict egress policy needsgithub.complus the relevant package registry reachable. cache: truereuses hook environments across runs; disable it when debugging a hook that appears to run against a stale environment.- Cold runs take the longest. The cache key is a hash of the prek config, with no fallback to an older entry, so the first run after a config change installs every hook environment from scratch, then uploads the cache, even when a hook failed. On a small runner that run can outlast the default 20 minutes: raise
timeout-minutesrather than turning the cache off, since every later run with the same config restores it. - The action is pinned by commit SHA rather than by tag, since a mutable tag is a supply-chain risk. Renovate bumps it via the trailing
# v3.0.0comment.