name: pre-commit description: run pre-commit inputs: extra_args: description: options to pass to pre-commit run required: false default: '--all-files' version: description: pre-commit version required: false default: '' runs: using: composite steps: - id: Install pre-commit (latest) if: ${{ inputs.version == '' }} run: python -m pip install pre-commit shell: bash - id: Install pre-commit ${{ inputs.version }} if: ${{ inputs.version != '' }} run: python -m pip install pre-commit==${{ inputs.version }} shell: bash - run: python -m pip freeze --local shell: bash - uses: actions/cache@v4 with: path: ~/.cache/pre-commit key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }} shell: bash