fix: remove spaces when doing existing comment comparison

This commit is contained in:
Michael Shick 2020-05-20 19:51:25 -04:00
parent dd915277b4
commit ba572be88f
No known key found for this signature in database
GPG key ID: ADF5BC9704BB4A61

View file

@ -67,11 +67,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;