Skip to content

Commit

Permalink
feat: check multiple pages for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bojanrajh committed Feb 19, 2024
1 parent 99692eb commit be91765
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ async function reportAll(
const issueNumber = Number(github.context.payload.pull_request?.number);
let createComment: boolean = true
if ('update' === commentOnPR) {
const comments = await octokit.rest.issues.listComments({
...github.context.repo,
issue_number: issueNumber,
})
const existingComment = comments.data.find(comment => comment.body.startsWith(title))
let existingComment, comments, page = 1;
do {
comments = await octokit.rest.issues.listComments({
...github.context.repo,
issue_number: issueNumber,
page,
})
existingComment = comments.data.find(comment => comment.body.startsWith(title))
page++
} while (!existingComment && comments.data.length > 0);

if (existingComment) {
if (logger.isDebugEnabled()) {
logger.debug(`Found Comment: ${existingComment.id}`)
Expand Down

0 comments on commit be91765

Please sign in to comment.