From 25d9ecd3f44633db4029181a0d7b89319e20b407 Mon Sep 17 00:00:00 2001 From: Donald Labaj Date: Wed, 16 Sep 2026 22:05:38 -0400 Subject: [PATCH] fix(CI): pass PR number as artifact instead of resolving it from workflow_run documentation-deploy.yml resolved the originating PR by falling back to GET /repos/{owner}/{repo}/commits/{sha}/pulls when workflow_run.pull_requests was empty, which GitHub leaves empty for every fork PR by design. That fallback itself doesn't reliably index fork-only commits either (confirmed empty via both REST and GraphQL for PR #12653's commits), so every fork PR deploy failed at Resolve PR number. Have documentation.yml save github.event.pull_request.number as its own artifact on the pull_request event (a value provided by GitHub, not influenced by the PR's contents) and have documentation-deploy.yml read it back instead of trying to look the PR up after the fact. Fixes #12655 Co-Authored-By: Claude Sonnet 5 --- .github/workflows/documentation-deploy.yml | 35 ++++++---------------- .github/workflows/documentation.yml | 11 +++++++ 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/workflows/documentation-deploy.yml b/.github/workflows/documentation-deploy.yml index 86d82fb0545..3968fea162c 100644 --- a/.github/workflows/documentation-deploy.yml +++ b/.github/workflows/documentation-deploy.yml @@ -6,7 +6,6 @@ on: permissions: actions: read contents: read - pull-requests: read jobs: deploy: name: Deploy @@ -25,33 +24,17 @@ jobs: with: skip-build: true - - name: Resolve PR number - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} - REPOSITORY: ${{ github.repository }} - WORKFLOW_PRS: ${{ toJSON(github.event.workflow_run.pull_requests) }} + - name: Download PR number + uses: actions/download-artifact@v4 + with: + name: pr-number + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Read PR number run: | set -euo pipefail - PR_COUNT=$(jq 'length // 0' <<< "${WORKFLOW_PRS:-null}") - if [ "$PR_COUNT" -eq 1 ]; then - PR_NUM=$(jq -r '.[0].number' <<< "$WORKFLOW_PRS") - elif [ "$PR_COUNT" -eq 0 ]; then - if ! [[ "$HEAD_SHA" =~ ^[0-9a-fA-F]{40,64}$ ]]; then - echo "Invalid source workflow head SHA" - exit 1 - fi - PR_JSON=$(gh api --paginate "repos/${REPOSITORY}/commits/${HEAD_SHA}/pulls") - PR_COUNT=$(jq 'length // 0' <<< "$PR_JSON") - if [ "$PR_COUNT" -ne 1 ]; then - echo "Failed to uniquely resolve PR number for commit ${HEAD_SHA} (found ${PR_COUNT} pull requests)" - exit 1 - fi - PR_NUM=$(jq -r '.[0].number' <<< "$PR_JSON") - else - echo "Ambiguous PR metadata: found ${PR_COUNT} pull requests on the source workflow run" - exit 1 - fi + PR_NUM=$(cat pr_number.txt) if ! [[ "$PR_NUM" =~ ^[0-9]+$ ]]; then echo "Failed to resolve a valid PR number" exit 1 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 1007a34ff9e..8bd38975c20 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -76,3 +76,14 @@ jobs: with: name: a11y-coverage path: packages/react-docs/coverage + + - name: Save PR number + if: github.event_name == 'pull_request' + run: echo "${{ github.event.pull_request.number }}" > pr_number.txt + + - name: Upload PR number + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: pr-number + path: pr_number.txt