Unverified 提交 da6abfe0 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Fix PR lookup in pr-review-responder workflow for fork PRs (#2323)

## Summary - Fixed the pr-review-responder workflow failing to find PRs from forks - Added a fallback that searches for open PRs using `pulls.list` API with the head repository owner and branch name when `workflow_run.pull_requests` array is empty ## Test plan - Create a PR from a fork with the `cc:request` label - Verify the workflow can now correctly find and process the PR #skip-bugbot Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes PR lookup in the pr-review-responder workflow for forked PRs. Adds a fallback search by head owner and branch when workflow_run.pull_requests is empty, so fork PRs are processed correctly. - **Bug Fixes** - Handle empty workflow_run.pull_requests for cross-repo PRs. - Use pulls.list with head "<owner>:<branch>" to find the PR number. - Exit early (should_continue=false) if no matching open PR is found. <sup>Written for commit 70e3c1399b438d5fe768aa9171ec2bf683bc38ff. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
上级 20938765
......@@ -30,13 +30,34 @@ jobs:
const run = context.payload.workflow_run;
// Get PR associated with this workflow run
if (!run.pull_requests || run.pull_requests.length === 0) {
console.log('No pull requests associated with this workflow run');
// Note: run.pull_requests can be empty for cross-repo PRs (forks)
// So we also search by head SHA as a fallback
let prNumber;
if (run.pull_requests && run.pull_requests.length > 0) {
prNumber = run.pull_requests[0].number;
} else {
// Search for PRs with matching head branch
// Note: head_repository can be null if the fork was deleted
if (!run.head_repository) {
console.log('Head repository not available');
core.setOutput('should_continue', 'false');
return;
}
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${run.head_repository.owner.login}:${run.head_branch}`
});
const prNumber = run.pull_requests[0].number;
if (prs.length === 0) {
console.log('No pull requests found for this workflow run');
core.setOutput('should_continue', 'false');
return;
}
prNumber = prs[0].number;
}
// Fetch full PR details to get labels
const { data: pr } = await github.rest.pulls.get({
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论