-
Notifications
You must be signed in to change notification settings - Fork 50
38 lines (32 loc) · 947 Bytes
/
pre-commit.yaml
File metadata and controls
38 lines (32 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: pre-commit
on:
workflow_dispatch:
pull_request:
branches:
- pybind11
push:
branches:
- pybind11
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit on changed files
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
base_ref="${{ github.event.pull_request.base.sha }}"
elif [[ -n "${{ github.event.before }}" && ! "${{ github.event.before }}" =~ ^0+$ ]]; then
base_ref="${{ github.event.before }}"
else
base_ref="$(git rev-parse HEAD~1)"
fi
pre-commit run --show-diff-on-failure --color=always --from-ref "$base_ref" --to-ref "${{ github.sha }}"