Skip to content

Commit 5c97194

Browse files
sbryngelsonclaude
andcommitted
Fix benchmark PR detection for cross-fork workflow_run events
workflow_run events for cross-fork PRs don't populate pull_requests[] and may report the base branch SHA instead of the PR head SHA, causing the SHA-based PR lookup to fail. Add a fallback that searches by branch name so benchmarks auto-trigger for fork PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f7d0164 commit 5c97194

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.github/workflows/bench.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ jobs:
5252
PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=open&sort=updated&direction=desc&per_page=30" \
5353
--jq ".[] | select(.head.sha == \"$HEAD_SHA\") | .number" | head -1)
5454
fi
55+
if [ -z "$PR_NUMBER" ]; then
56+
# workflow_run may report the merge/base SHA for forks. Fall back to branch name.
57+
HEAD_BRANCH="${{ github.event.workflow_run.head_branch }}"
58+
if [ -n "$HEAD_BRANCH" ] && [ "$HEAD_BRANCH" != "master" ]; then
59+
PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=open&sort=updated&direction=desc&per_page=30" \
60+
--jq ".[] | select(.head.ref == \"$HEAD_BRANCH\") | .number" | head -1)
61+
fi
62+
fi
5563
5664
if [ -n "$PR_NUMBER" ]; then
5765
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)