Skip to content

Commit

Permalink
fix: delete all comments with pattern instead of one
Browse files Browse the repository at this point in the history
  • Loading branch information
thollander committed Aug 6, 2023
1 parent 64cca84 commit 42747a0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ async function run() {
type ListCommentsResponseDataType = GetResponseDataTypeFromEndpointMethod<
typeof octokit.rest.issues.listComments
>;
let comment: ListCommentsResponseDataType[0] | undefined;
let comments: ListCommentsResponseDataType = [];
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
...context.repo,
issue_number,
})) {
comment = comments.find((comment) => comment?.body?.includes(comment_tag_pattern));
if (comment) break;
comments.push(...comments.filter((comment) => comment?.body?.includes(comment_tag_pattern)));
}

if (comment) {
core.info(`Deleting comment ${comment.id}.`);
await octokit.rest.issues.deleteComment({
...context.repo,
comment_id: comment.id,
});
if (comments.length > 0) {
for (const comment of comments) {
core.info(`Deleting comment ${comment.id}.`);
await octokit.rest.issues.deleteComment({
...context.repo,
comment_id: comment.id,
});
}
return;
}
}
Expand Down

0 comments on commit 42747a0

Please sign in to comment.