Skip to content

Commit c786fc5

Browse files
authored
chore(ci): Fix double issue creation for unreferenced PRs (#18442)
This fixes a problem, where our unreferenced PR GH workflow would trigger another new issue being created because of a race condition between creating the issue and updating the PR description automatically.
1 parent a6eec86 commit c786fc5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
return;
4242
}
4343
44+
// Bail if this edit was made by the GitHub Actions bot (this workflow)
45+
// This prevents infinite loops when we update the PR body with the new issue reference
46+
// We check login specifically to not skip edits from other legitimate bots
47+
if (context.payload.sender && context.payload.sender.login === 'github-actions[bot]') {
48+
console.log(`PR #${pr.number} was edited by github-actions[bot] (this workflow), skipping.`);
49+
return;
50+
}
51+
4452
// Check if the PR is already approved
4553
const reviewsResponse = await github.rest.pulls.listReviews({
4654
owner: context.repo.owner,
@@ -109,7 +117,7 @@ jobs:
109117
console.log(`Created issue #${issueID}.`);
110118
111119
// Update the PR body to reference the new issue
112-
const updatedPrBody = `${prBody}\n\nCloses #${issueID}`;
120+
const updatedPrBody = `${prBody}\n\nCloses #${issueID} (added automatically)`;
113121
114122
await github.rest.pulls.update({
115123
owner: context.repo.owner,

0 commit comments

Comments
 (0)