A GitHub Action that runs pre-commit hooks using prek in your CI/CD pipeline.
Despite the name, pre-commit hooks can be run at any time, not just before commits.
prek is a fast hooks runner that provides an alternative to the widely-used pre-commit framework. It offers better performance and caching capabilities for running code quality checks.
name: Prek checks on: [push, pull_request] jobs: prek: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1 with: extra-args: '--all-files --directory packages/'steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1 with: extra-args: '--all-files mypy flake8 ruff'steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1 with: prek-version: '0.2.1' extra-args: '--all-files'steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1 with: install-only: true - run: | prek run \ --show-diff-on-failure \ --color alwaysWhen install-only is set to true, the action will only install prek and skip running it. The extra-args input has no effect in this mode.
Running prek in a separate step can be useful for example when you need to customize the environment.
| Input | Description | Required | Default |
|---|---|---|---|
extra-args | Additional arguments to pass to prek run | No | --all-files |
install-only | Only install prek, do not run it | No | false |
prek-version | Version of prek to install (e.g., '0.2.1', 'latest') | No | latest |
working-directory | The working directory to run prek in | No | . |
token | GitHub token to avoid API rate limiting | No | ${{ github.token }} |
| Output | Description |
|---|---|
prek-version | The resolved version of prek that was installed |
Your repository must have a .pre-commit-config.yaml file configured for use with pre-commit hooks.
This action is licensed under the MIT License. See LICENSE for details.