From 71ed76a5520ab6c7e054ecb20e71435723ec7621 Mon Sep 17 00:00:00 2001 From: Joshua Hale Date: Tue, 31 Mar 2026 10:35:49 +0100 Subject: [PATCH] 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> --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index fb84c7d..3b7037e 100644 --- a/action.yml +++ b/action.yml @@ -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