9
0
Fork 0
mirror of https://github.com/pre-commit/action.git synced 2026-02-11 13:49:23 +00:00
pre-commit-action/action.yml
2026-01-20 14:56:06 +01:00

28 lines
1.1 KiB
YAML

name: pre-commit
description: run pre-commit
inputs:
extra_args:
description: options to pass to pre-commit run
required: false
default: '--all-files'
shared-cache:
description: enable shared cache across branches
required: false
default: 'false'
runs:
using: composite
steps:
- run: python -m pip install pre-commit
shell: bash
- run: python -m pip freeze --local
shell: bash
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
# Key matches pre-commit action format: pre-commit-3|pythonLocation|configHash
# The restore-key will find caches from ANY branch with the same Python location and config hash
# This allows sharing caches across branches when .pre-commit-config.yaml hasn't changed
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: ${{ inputs.shared-cache == 'true' && format('pre-commit-3|{0}|{1}', env.pythonLocation, hashFiles('.pre-commit-config.yaml')) || '' }}
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
shell: bash