Run prek in your GitHub Actions workflows.
name: Prek checks
on: [push, pull_request]
jobs:
prek:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0prek is always invoked as:
prek run --show-diff-on-failure --color=always <extra-args>
For v2 and earlier releases, major and minor tags such as v2 and v2.0 are moving tags. Starting with v3, major and minor tags are no longer published. Always use an exact version such as j178/[email protected]; for stronger protection against supply-chain attacks, pin to a full commit SHA.
| Input | Description | Required | Default |
|---|---|---|---|
extra-args |
Additional arguments appended to prek run --show-diff-on-failure --color=always |
No | --all-files |
extra_args |
Deprecated alias for extra-args |
No | |
prek-version |
Version or semver range to install, for example 0.2.30, 0.3.x, <=1.0.0, latest, or latest-known |
No | latest |
sha256 |
SHA-256 checksum of the release archive; overrides the bundled checksum | No | |
install-only |
Install prek but skip prek run |
No | false |
working-directory |
Directory where prek run is executed |
No | . |
show-verbose-logs |
Print the prek verbose log after prek run completes |
No | true |
cache |
Cache the prek environment between workflow runs | No | true |
| Output | Description |
|---|---|
prek-version |
The resolved prek version, normalized to a v-prefixed tag |
cache-hit |
Whether the restored prek cache exactly matched the computed primary cache key |
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0
with:
extra-args: '--all-files --directory packages/'steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0
with:
prek-version: '0.2.30'Use latest-known to select the newest stable prek version in this action's
bundled checksum table. The version is resolved locally and only changes when you
update the action.
with:
prek-version: 'latest-known'Downloaded release archives are automatically verified using checksums bundled
with this action. For newer versions whose checksums are not yet bundled, you
can specify a checksum with sha256:
with:
prek-version: '0.5.6'
sha256: 'b0c1a9fdaf0f379c1c2809481a1e1560a4a233777ecd3c38d3e7459d77a59398'SHA-256 hashes are available on the prek releases page.
Use the checksum for your runner's platform, architecture, and libc.
An explicit sha256 overrides the bundled checksum.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0
with:
prek-version: '0.3.x'steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0
with:
install-only: true
- run: prek run --show-diff-on-failure --color=always --all-filessteps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0
with:
show-verbose-logs: falseThe target repository needs a prek or pre-commit configuration file:
prek.toml.pre-commit-config.yaml.pre-commit-config.yml
For contributor setup, testing, bundling, and release steps, see CONTRIBUTING.md.