8000 GitHub - andrewaylett/pre-commit-action: a GitHub action to run `pre-commit`
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andrewaylett/pre-commit-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

andrewaylett/pre-commit-action

a GitHub action to run pre-commit

using this action

To use this action, make a file .github/workflows/pre-commit.yml. Here's a template to get started:

name: pre-commit

on:
  pull_request:
  push:
    branches: [main]

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
    - uses: andrewaylett/pre-commit-action@a975c0a22b967c4d0f8b70a01aadb01b50a1f2eb # v4

This does a few things:

  • clones the code
  • sets up the pre-commit cache

using this action with custom invocations

By default, this action runs all the hooks against all the files. extra_args lets users specify a single hook id and/or options to pass to pre-commit run.

Here's a sample step configuration that only runs the flake8 hook against all the files (use the template above except for the pre-commit action):

    - uses: andrewaylett/pre-commit-action@a975c0a22b967c4d0f8b70a01aadb01b50a1f2eb # v4
      with:
        extra_args: flake8 --all-files

Note that the --all-files flag is specified as a default extra argument, and needs to be re-added if the default is overridden.

History

This repository is forked from pre-commit/action, which was maintained by the authors of pre-commit until they started their own CI service.

Having not found https://pre-commit.ci to be suitable for my use-cases, I have continued to use the out-of-support GitHub Action. It still works, but the warnings (and outdated dependencies) make me prefer to maintain my own fork.

Maintenance

Renovate will bump versions of tools that this project depends on. Once that's working properly, it includes bumping the default pre-commit version in actions.yaml. The main GitHub actions workflow tags each commit to main with the version of pre-commit that's in use and a counter to keep track of releases of that version number.

I recommend consumers use Mend Renovate or similar to pin to specific commits, but the Actions workflow will maintain a major version tag that you may use if you prefer.

About

a GitHub action to run `pre-commit`

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 17

0