Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
thollander committed Aug 6, 2023
1 parent acc95a6 commit d3a2f2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
12 changes: 4 additions & 8 deletions lib/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9561,22 +9561,18 @@ async function run() {
}
const comment_tag_pattern = `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`;
if (comment_tag_pattern) {
let comments = [];
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
...context.repo,
issue_number,
})) {
comments.push(...comments.filter((comment) => comment?.body?.includes(comment_tag_pattern)));
}
if (comments.length > 0) {
for (const comment of comments) {
core.info(`Deleting comment ${comment.id}.`);
const commentsToDelete = comments.filter((comment) => comment?.body?.includes(comment_tag_pattern));
for (const commentToDelete of commentsToDelete) {
core.info(`Deleting comment ${commentToDelete.id}.`);
await octokit.rest.issues.deleteComment({
...context.repo,
comment_id: comment.id,
comment_id: commentToDelete.id,
});
}
return;
}
}
return;
Expand Down
16 changes: 4 additions & 12 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,18 @@ async function run() {
const comment_tag_pattern = `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`;

if (comment_tag_pattern) {
type ListCommentsResponseDataType = GetResponseDataTypeFromEndpointMethod<
typeof octokit.rest.issues.listComments
>;
let comments: ListCommentsResponseDataType = [];
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
...context.repo,
issue_number,
})) {
comments.push(...comments.filter((comment) => comment?.body?.includes(comment_tag_pattern)));
}

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

0 comments on commit d3a2f2d

Please sign in to comment.