Skip coverage upload for fork PRs

Fork PR tokens don't have write access to the base repo, so the
upload would fail with 403. Detect this early and exit with a
notice instead of a red CI step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Joshua Hale
2026-03-31 10:35:49 +01:00
parent ca786bcab9
commit 71ed76a552
+8
View File
@@ -34,6 +34,14 @@ runs:
exit 1
fi
# Skip coverage upload for fork PRs — the token won't have write
# permissions to the base repository.
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "::notice::Skipping coverage upload for fork PR (from ${{ github.event.pull_request.head.repo.full_name }})"
exit 0
fi
# Resolve the commit SHA and ref. On pull_request events, github.sha
# and github.ref point to the merge commit — use the PR head instead.
if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "pull_request_target" ]; then