|
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@v6 |
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@v6 |
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 }} |
|
56 | 57 | run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure |
57 | 58 | continue-on-error: true |
58 | 59 | - name: Commit and push changes |
59 | | - if: env.IS_FORK == 'false' |
| 60 | + if: env.HAS_SECRETS == 'true' |
60 | 61 | run: | |
61 | 62 | git config user.name "github-actions[bot]" |
62 | 63 | git config user.email "github-actions[bot]@users.noreply.github.com" |
|
68 | 69 | git push |
69 | 70 | fi |
70 | 71 | - uses: pre-commit-ci/lite-action@v1.1.0 |
71 | | - if: env.IS_FORK == 'true' |
| 72 | + if: env.HAS_SECRETS == 'false' |
72 | 73 | with: |
73 | 74 | msg: 🎨 Auto format |
74 | 75 | - name: Error out on pre-commit errors |
|
0 commit comments