From 4d887b477c96eb29a6ee9fe7bcb5f2bbc94f0ca3 Mon Sep 17 00:00:00 2001 From: Michael Shick Date: Wed, 20 May 2020 19:51:37 -0400 Subject: [PATCH] fix: remove spaces when doing existing comment comparison --- dist/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 046fbcb..bc6a400 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2054,11 +2054,17 @@ async function run() { issue_number: issueNumber, }); - const filteredComments = comments.filter( - (c) => c.body === message && c.user.login === "github-actions[bot]" + const spacesRe = new RegExp("\\s", "g"); + const messageClean = message.replace(spacesRe, ""); + + const commentExists = comments.some( + (c) => + // First find candidate bot messages to avoid extra processing( + c.user.login === "github-actions[bot]" && + c.body.replace(spacesRe, "") === messageClean ); - if (filteredComments.length) { + if (commentExists) { core.info("the issue already contains this message"); core.setOutput("comment-created", "false"); return;