From a994ad364257a1d8c47978d0304ef500cc5d2c88 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:28:15 +1000 Subject: [PATCH] Workflow - check all comments to find previous bot comment (#9815) --- .github/workflows/external-component-bot.yml | 26 ++++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/external-component-bot.yml b/.github/workflows/external-component-bot.yml index 5f5bc703ad..29103e8eee 100644 --- a/.github/workflows/external-component-bot.yml +++ b/.github/workflows/external-component-bot.yml @@ -61,7 +61,8 @@ jobs: } async function createComment(octokit, owner, repo, prNumber, esphomeChanges, componentChanges) { - const commentMarker = ""; + const commentMarker = ""; + const legacyCommentMarker = ""; let commentBody; if (esphomeChanges.length === 1) { commentBody = generateExternalComponentInstructions(prNumber, componentChanges, owner, repo); @@ -71,14 +72,23 @@ jobs: commentBody += `\n\n---\n(Added by the PR bot)\n\n${commentMarker}`; // Check for existing bot comment - const comments = await github.rest.issues.listComments({ - owner: owner, - repo: repo, - issue_number: prNumber, - }); + const comments = await github.paginate( + github.rest.issues.listComments, + { + owner: owner, + repo: repo, + issue_number: prNumber, + per_page: 100, + } + ); - const botComment = comments.data.find(comment => - comment.body.includes(commentMarker) + const sorted = comments.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at)); + + const botComment = sorted.find(comment => + ( + comment.body.includes(commentMarker) || + comment.body.includes(legacyCommentMarker) + ) && comment.user.type === "Bot" ); if (botComment && botComment.body === commentBody) {