Skip to content

Commit a12c059

Browse files
committed
Fix pin bump CI handler not triggering on PR #19048
Two bugs: workflow_run.pull_requests was empty (known GitHub API limitation), so fall back to looking up the PR by branch name. Also handle cancelled trunk conclusion, which happens when docker-builds fails and Linux jobs can't start. This PR was authored with help from Claude.
1 parent 2d995bc commit a12c059

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

.github/workflows/pin-bump-ci-handler.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@ jobs:
2222
const workflowRun = context.payload.workflow_run;
2323
const conclusion = workflowRun.conclusion;
2424
const runUrl = workflowRun.html_url;
25+
const headBranch = workflowRun.head_branch;
2526
27+
// Find PR by branch name (workflow_run.pull_requests is unreliable)
28+
let prNumber;
2629
const prs = workflowRun.pull_requests;
27-
if (!prs || prs.length === 0) {
28-
console.log('No PRs associated with this workflow run. Skipping.');
29-
return;
30+
if (prs && prs.length > 0) {
31+
prNumber = prs[0].number;
32+
} else {
33+
const { data: branchPrs } = await github.rest.pulls.list({
34+
owner, repo, head: `${owner}:${headBranch}`, state: 'open', per_page: 1
35+
});
36+
if (branchPrs.length === 0) {
37+
console.log(`No open PRs for branch ${headBranch}. Skipping.`);
38+
return;
39+
}
40+
prNumber = branchPrs[0].number;
3041
}
3142
32-
const prNumber = prs[0].number;
3343
const pr = await github.rest.pulls.get({ owner, repo, pull_number: prNumber });
3444
3545
const isPinBump = pr.data.labels.some(l => l.name === 'ci/pytorch-pin-bump');
@@ -65,8 +75,8 @@ jobs:
6575
return;
6676
}
6777
68-
if (conclusion !== 'failure') {
69-
console.log(`Trunk concluded with "${conclusion}" (not failure). Skipping.`);
78+
if (conclusion !== 'failure' && conclusion !== 'cancelled') {
79+
console.log(`Trunk concluded with "${conclusion}" (not failure/cancelled). Skipping.`);
7080
return;
7181
}
7282

0 commit comments

Comments
 (0)