Skip to content

Commit 1ed055b

Browse files
committed
preview: Use a different approach to get the PR number
1 parent 4126333 commit 1ed055b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.github/workflows/preview.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ jobs:
2020
steps:
2121
- name: Get PR number
2222
id: pr
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2325
run: |
24-
PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
25-
if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" = "0" ]; then
26-
echo "No PR number found"
26+
PR_NUMBER=$(gh api repos/${{ github.repository }}/pulls \
27+
--jq ".[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\") | .number")
28+
if [ -z "$PR_NUMBER" ]; then
29+
echo "No PR found for SHA ${{ github.event.workflow_run.head_sha }}"
2730
exit 1
2831
fi
2932
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)