-
Notifications
You must be signed in to change notification settings - Fork 121
46 lines (40 loc) · 1.37 KB
/
pre-commit.yml
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
39
40
41
42
43
44
45
46
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
# Fetch the previous commit to be able to check for changes
fetch-depth: 2
- name: "Detect code style issues (push)"
uses: pre-commit/[email protected]
if: github.event_name == 'push'
env:
SKIP: rstcheck,ignore-pot-creation-date
- name: "Detect code style issues (pull_request)"
uses: pre-commit/[email protected]
if: github.event_name == 'pull_request'
env:
SKIP: rstcheck
with:
# HEAD is the not yet integrated PR merge commit +refs/pull/xxxx/merge
# HEAD^1 is the PR target branch and HEAD^2 is the HEAD of the source branch
extra_args: --from-ref HEAD^1 --to-ref HEAD
- name: "Generate patch file"
if: failure()
run: |
git diff-index -p HEAD > "${PATCH_FILE}"
[ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}"
env:
PATCH_FILE: pre-commit.patch
- name: "Upload patch artifact"
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}