From 8c126e98dad9165a0cf64440a0879eadc2973edb Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 25 Aug 2026 00:38:02 -0500 Subject: [PATCH] fix(ci): check PR body for linked issue on non-default branches (#43964) Signed-off-by: Major Hayden --- .github/workflows/pr-standards.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-standards.yml b/.github/workflows/pr-standards.yml index 06838089d35..0d4bb85537e 100644 --- a/.github/workflows/pr-standards.yml +++ b/.github/workflows/pr-standards.yml @@ -135,7 +135,16 @@ jobs: const linkedIssues = result.repository.pullRequest.closingIssuesReferences.totalCount; - if (linkedIssues === 0) { + // GitHub only populates closingIssuesReferences when a PR targets the repository's + // default branch (dev). PRs targeting other branches like v2 always return totalCount 0. + // Fall back to checking the PR description for closing keywords (e.g. Closes #123). + const body = pr.body || ''; + const issueMatch = body.match(/### Issue for this PR\s*\n([\s\S]*?)(?=###|$)/); + const issueContent = issueMatch ? issueMatch[1].trim() : body; + const hasBodyIssueRef = /(closes|fixes|resolves)\s+#\d+/i.test(issueContent) || /#\d+/.test(issueContent); + const hasLinkedIssue = linkedIssues > 0 || hasBodyIssueRef; + + if (!hasLinkedIssue) { await addLabel('needs:issue'); await comment('issue', `Thanks for your contribution!