diff --git a/.github/workflows/create-issue-for-unreferenced-pr.yml b/.github/workflows/create-issue-for-unreferenced-pr.yml index cfe192e068..60ecfbefca 100644 --- a/.github/workflows/create-issue-for-unreferenced-pr.yml +++ b/.github/workflows/create-issue-for-unreferenced-pr.yml @@ -68,6 +68,18 @@ jobs: return; } + // Check if there's already an issue created by this automation for this PR + // Search for issues that mention this PR and were created by github-actions bot + const existingIssuesResponse = await github.rest.search.issuesAndPullRequests({ + q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open author:app/github-actions "${prUrl}" in:title in:body`, + }); + + if (existingIssuesResponse.data.total_count > 0) { + const existingIssue = existingIssuesResponse.data.items[0]; + console.log(`An issue (#${existingIssue.number}) already exists for PR #${prNumber}, skipping creation.`); + return; + } + core.warning(`PR #${prNumber} does not have an issue reference. Creating a new issue so it can be tracked in Linear.`); // Construct the title and body for the new issue