Skip to content

Commit 8333bb6

Browse files
committed
ci(preview-readme): skip fork PRs to fix checkout failure
The preview-readme job checks out the head branch by name (ref: github.event.pull_request.head.ref) without setting repository, so actions/checkout fetches refs/heads/<branch> from this repo. For a fork PR the branch lives only in the fork, so the fetch finds no ref and the step fails with 'git failed with exit code 1' (seen on PR #28, from gaul/s3proxy-chart). Every other workflow uses the default merge-ref checkout and is unaffected. Even with checkout fixed, the comment-posting steps need a write-scoped GITHUB_TOKEN, which the pull_request event does not grant fork PRs, so the preview feature is inherently limited to same-repo branches. Guard the job on head.repo.full_name == github.repository: internal branches still get the README preview; fork PRs skip it cleanly instead of reporting a spurious failure.
1 parent 1e3d2d5 commit 8333bb6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.github/workflows/preview-readme.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ on:
1010

1111
jobs:
1212
preview-readme:
13+
# This job checks out the head branch by name and posts the rendered README
14+
# diff back as a PR comment. Both of those require the head branch to live in
15+
# this repo and a write-scoped GITHUB_TOKEN. Neither holds for fork PRs: the
16+
# branch exists only in the fork (so `actions/checkout` with a bare `ref:`
17+
# fetches refs/heads/<branch> from this repo and fails), and the
18+
# pull_request event grants forks a read-only token (so createComment 403s).
19+
# Skip forks; internal branches still get the preview.
20+
if: github.event.pull_request.head.repo.full_name == github.repository
1321
runs-on: ubuntu-latest
1422
timeout-minutes: 5
1523
steps:

0 commit comments

Comments
 (0)