|
7 | 7 | - synchronize |
8 | 8 |
|
9 | 9 | env: |
10 | | - IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }} |
| 10 | + # Forks and Dependabot don't have access to secrets |
| 11 | + HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }} |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | pre-commit: |
|
19 | 20 | run: echo "$GITHUB_CONTEXT" |
20 | 21 | - uses: actions/checkout@v5 |
21 | 22 | name: Checkout PR for own repo |
22 | | - if: env.IS_FORK == 'false' |
| 23 | + if: env.HAS_SECRETS == 'true' |
23 | 24 | with: |
24 | 25 | # To be able to commit it needs to fetch the head of the branch, not the |
25 | 26 | # merge commit |
|
31 | 32 | # pre-commit lite ci needs the default checkout configs to work |
32 | 33 | - uses: actions/checkout@v5 |
33 | 34 | name: Checkout PR for fork |
34 | | - if: env.IS_FORK == 'true' |
| 35 | + if: env.HAS_SECRETS == 'false' |
35 | 36 | with: |
36 | 37 | # To be able to commit it needs the head branch of the PR, the remote one |
37 | 38 | ref: ${{ github.event.pull_request.head.sha }} |
|
54 | 55 | run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure |
55 | 56 | continue-on-error: true |
56 | 57 | - name: Commit and push changes |
57 | | - if: env.IS_FORK == 'false' |
| 58 | + if: env.HAS_SECRETS == 'true' |
58 | 59 | run: | |
59 | 60 | git config user.name "github-actions[bot]" |
60 | 61 | git config user.email "github-actions[bot]@users.noreply.github.com" |
|
66 | 67 | git push |
67 | 68 | fi |
68 | 69 | - uses: pre-commit-ci/lite-action@v1.1.0 |
69 | | - if: env.IS_FORK == 'true' |
| 70 | + if: env.HAS_SECRETS == 'false' |
70 | 71 | with: |
71 | 72 | msg: 🎨 Auto format |
72 | 73 | - name: Error out on pre-commit errors |
|
0 commit comments