GitHub Action: pre-commit
A GitHub action to run pre-commit
Introduction
This action is a fork of pre-commit/action that adds optional features for private repositories.
Permissions required: repo and workflow.
Usage
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: cloudposse/github-action-pre-[email protected]
To run a specific hook or pass custom arguments:
- uses: cloudposse/github-action-pre-[email protected]
with:
extra_args: flake8 --all-files
For private repositories, configure push-back support:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cloudposse/github-action-pre-[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
git_user_name: pre-commit
git_user_email: pre-[email protected]
git_commit_message: pre-commit fixes
Inputs
| Name | Description | Default | Required |
|---|---|---|---|
| extra_args | options to pass to pre-commit run | --all-files | false |
| git_commit_message | github commit message to push with | pre-commit fixes | false |
| git_user_email | github user email to push with | [email protected] | false |
| git_user_name | github user name to push with | pre-commit | false |
| token | github token to clone / push with | N/A | false |