From a12c0597edde2d33c290f13dba3f4bf2aef316a5 Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Wed, 22 Apr 2026 14:40:29 -0700 Subject: [PATCH] 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. --- .github/workflows/pin-bump-ci-handler.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pin-bump-ci-handler.yml b/.github/workflows/pin-bump-ci-handler.yml index b07ac8307df..298061e9468 100644 --- a/.github/workflows/pin-bump-ci-handler.yml +++ b/.github/workflows/pin-bump-ci-handler.yml @@ -22,14 +22,24 @@ jobs: const workflowRun = context.payload.workflow_run; const conclusion = workflowRun.conclusion; const runUrl = workflowRun.html_url; + const headBranch = workflowRun.head_branch; + // Find PR by branch name (workflow_run.pull_requests is unreliable) + let prNumber; const prs = workflowRun.pull_requests; - if (!prs || prs.length === 0) { - console.log('No PRs associated with this workflow run. Skipping.'); - return; + if (prs && prs.length > 0) { + prNumber = prs[0].number; + } else { + const { data: branchPrs } = await github.rest.pulls.list({ + owner, repo, head: `${owner}:${headBranch}`, state: 'open', per_page: 1 + }); + if (branchPrs.length === 0) { + console.log(`No open PRs for branch ${headBranch}. Skipping.`); + return; + } + prNumber = branchPrs[0].number; } - const prNumber = prs[0].number; const pr = await github.rest.pulls.get({ owner, repo, pull_number: prNumber }); const isPinBump = pr.data.labels.some(l => l.name === 'ci/pytorch-pin-bump'); @@ -65,8 +75,8 @@ jobs: return; } - if (conclusion !== 'failure') { - console.log(`Trunk concluded with "${conclusion}" (not failure). Skipping.`); + if (conclusion !== 'failure' && conclusion !== 'cancelled') { + console.log(`Trunk concluded with "${conclusion}" (not failure/cancelled). Skipping.`); return; }