Skip to content

Commit 25f6a17

Browse files
committed
fix: Prevent duplicate issue creation in PR automation workflow
The workflow was creating duplicate issues when multiple trigger events (opened, edited, synchronize, etc.) fired in quick succession. Both workflow runs would check the PR simultaneously, find no issue reference, and each create a new issue. Added a check to search for existing issues created by this automation before creating a new one. The workflow now searches for open issues that contain the PR URL and were created by github-actions bot, preventing duplicate issue creation. Fixes the issue where PR #6386 had two issues created (#6499 and #6500).
1 parent debf3e9 commit 25f6a17

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.github/workflows/create-issue-for-unreferenced-pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ jobs:
6868
return;
6969
}
7070
71+
// Check if there's already an issue created by this automation for this PR
72+
// Search for issues that mention this PR and were created by github-actions bot
73+
const existingIssuesResponse = await github.rest.search.issuesAndPullRequests({
74+
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open "${prUrl}" author:app/github-actions in:body`,
75+
});
76+
77+
if (existingIssuesResponse.data.total_count > 0) {
78+
const existingIssue = existingIssuesResponse.data.items[0];
79+
console.log(`An issue (#${existingIssue.number}) already exists for PR #${prNumber}, skipping creation.`);
80+
return;
81+
}
82+
7183
core.warning(`PR #${prNumber} does not have an issue reference. Creating a new issue so it can be tracked in Linear.`);
7284
7385
// Construct the title and body for the new issue

0 commit comments

Comments
 (0)