From 195078e91d48b0722b8e1bf8f237c95a8b6f83f4 Mon Sep 17 00:00:00 2001 From: Jordan Ritter Date: Fri, 15 May 2026 12:28:40 -0700 Subject: [PATCH] fix(ci): skip PR tarball publish on non-PR workflow runs workflow_run fires for both PR and push events. When the triggering run has no associated PR (e.g. a push to main), the pull_requests array is empty and the publish step errors. Exit gracefully instead, gating all subsequent steps on the skip output. --- .github/workflows/pr-tarball-publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-tarball-publish.yml b/.github/workflows/pr-tarball-publish.yml index 5f732467e..7daa4da8d 100644 --- a/.github/workflows/pr-tarball-publish.yml +++ b/.github/workflows/pr-tarball-publish.yml @@ -28,12 +28,14 @@ jobs: PR_NUMBER=$(gh api "repos/${REPO}/actions/runs/${RUN_ID}" \ --jq '.pull_requests[0].number') if [[ -z "$PR_NUMBER" || "$PR_NUMBER" == "null" ]]; then - echo "::error::Could not determine PR number from workflow run" - exit 1 + echo "No PR associated with this workflow run (likely a push to main). Skipping." + echo "skip=true" >> "$GITHUB_OUTPUT" + exit 0 fi echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - name: Download tarball artifact + if: steps.pr.outputs.skip != 'true' uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: pr-tarball @@ -41,12 +43,14 @@ jobs: github-token: ${{ github.token }} - name: Get tarball info + if: steps.pr.outputs.skip != 'true' id: tarball run: | TARBALL_NAME=$(ls *.tgz | head -1 | xargs basename) echo "name=$TARBALL_NAME" >> "$GITHUB_OUTPUT" - name: Create or update PR release + if: steps.pr.outputs.skip != 'true' id: release env: GH_TOKEN: ${{ github.token }} @@ -72,6 +76,7 @@ jobs: echo "url=$DOWNLOAD_URL" >> "$GITHUB_OUTPUT" - name: Comment on PR + if: steps.pr.outputs.skip != 'true' uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4 with: number: ${{ steps.pr.outputs.number }}