|
8 | 8 | pre-commit: |
9 | 9 | runs-on: ubuntu-latest |
10 | 10 | steps: |
11 | | - - uses: actions/checkout@v6 |
12 | | - - uses: actions/setup-python@v6 |
13 | | - - uses: pre-commit/action@v3.0.1 |
14 | | - env: |
15 | | - SKIP: rstcheck |
| 11 | + - name: "Check out repository" |
| 12 | + uses: actions/checkout@v7 |
| 13 | + with: |
| 14 | + # Fetch the previous commit to be able to check for changes |
| 15 | + fetch-depth: 2 |
16 | 16 |
|
17 | | - - name: "Generate patch file" |
18 | | - if: failure() |
19 | | - run: | |
20 | | - git diff-index -p HEAD > "${PATCH_FILE}" |
21 | | - [ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}" |
22 | | - env: |
23 | | - PATCH_FILE: pre-commit.patch |
| 17 | + - name: "Detect code style issues (push)" |
| 18 | + uses: pre-commit/action@v3.0.1 |
| 19 | + if: github.event_name == 'push' |
| 20 | + env: |
| 21 | + SKIP: rstcheck,ignore-pot-creation-date |
24 | 22 |
|
25 | | - - name: "Upload patch artifact" |
26 | | - if: failure() && env.UPLOAD_PATCH_FILE != null |
27 | | - uses: actions/upload-artifact@v6 |
28 | | - with: |
29 | | - name: ${{ env.UPLOAD_PATCH_FILE }} |
30 | | - path: ${{ env.UPLOAD_PATCH_FILE }} |
| 23 | + - name: "Detect code style issues (pull_request)" |
| 24 | + uses: pre-commit/action@v3.0.1 |
| 25 | + if: github.event_name == 'pull_request' |
| 26 | + env: |
| 27 | + SKIP: rstcheck |
| 28 | + with: |
| 29 | + # HEAD is the not yet integrated PR merge commit +refs/pull/xxxx/merge |
| 30 | + # HEAD^1 is the PR target branch and HEAD^2 is the HEAD of the source branch |
| 31 | + extra_args: --from-ref HEAD^1 --to-ref HEAD |
| 32 | + |
| 33 | + - name: "Generate patch file" |
| 34 | + if: failure() |
| 35 | + run: | |
| 36 | + git diff-index -p HEAD > "${PATCH_FILE}" |
| 37 | + [ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}" |
| 38 | + env: |
| 39 | + PATCH_FILE: pre-commit.patch |
| 40 | + |
| 41 | + - name: "Upload patch artifact" |
| 42 | + if: failure() && env.UPLOAD_PATCH_FILE != null |
| 43 | + uses: actions/upload-artifact@v7 |
| 44 | + with: |
| 45 | + name: ${{ env.UPLOAD_PATCH_FILE }} |
| 46 | + path: ${{ env.UPLOAD_PATCH_FILE }} |
0 commit comments