diff --git a/.github/workflows/create-issue-for-unreferenced-prs.yml b/.github/workflows/create-issue-for-unreferenced-prs.yml index a0eee060f282..a47df32738d7 100644 --- a/.github/workflows/create-issue-for-unreferenced-prs.yml +++ b/.github/workflows/create-issue-for-unreferenced-prs.yml @@ -41,6 +41,14 @@ jobs: return; } + // Bail if this edit was made by the GitHub Actions bot (this workflow) + // This prevents infinite loops when we update the PR body with the new issue reference + // We check login specifically to not skip edits from other legitimate bots + if (context.payload.sender && context.payload.sender.login === 'github-actions[bot]') { + console.log(`PR #${pr.number} was edited by github-actions[bot] (this workflow), skipping.`); + return; + } + // Check if the PR is already approved const reviewsResponse = await github.rest.pulls.listReviews({ owner: context.repo.owner, @@ -109,7 +117,7 @@ jobs: console.log(`Created issue #${issueID}.`); // Update the PR body to reference the new issue - const updatedPrBody = `${prBody}\n\nCloses #${issueID}`; + const updatedPrBody = `${prBody}\n\nCloses #${issueID} (added automatically)`; await github.rest.pulls.update({ owner: context.repo.owner,