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