From ed4d3a59dfe131c1bd46f0d2d57725daad6071d4 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 19 Mar 2021 15:30:39 +0800 Subject: [PATCH] fix: list comments miss. --- CHANGELOG.md | 6 ++++++ dist/index.js | 22 ++++++++++++++++------ src/main.js | 22 ++++++++++++++++------ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 269de69..62c65cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v1.2.1 + +`2021.03.19` + +- fix: list comments miss. + ## v1.2.0 - feat: add outputs `comment-id`. diff --git a/dist/index.js b/dist/index.js index 832afaf..25531ab 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7086,14 +7086,24 @@ async function run() { return false; } - const res = await octokit.issues.listComments({ - owner, - repo, - issue_number: number, - }); + async function listComments(page = 1) { + let { data: comments } = await octokit.issues.listComments({ + owner, + repo, + issue_number: number, + per_page: 100, + page, + }); + if (comments.length >= 100) { + comments = comments.concat(await listComments(page + 1)); + } + return comments; + } + + const commentList = await listComments(); core.info(`Actions: [find-comments][${number}] success!`); let comments = []; - res.data.forEach(item => { + commentList.forEach(item => { const a = commentAuth ? item.user.login === commentAuth : true; const b = bodyInclude ? item.body.includes(bodyInclude) : true; if (a && b) { diff --git a/src/main.js b/src/main.js index ca54e85..9ac8a87 100644 --- a/src/main.js +++ b/src/main.js @@ -42,14 +42,24 @@ async function run() { return false; } - const res = await octokit.issues.listComments({ - owner, - repo, - issue_number: number, - }); + async function listComments(page = 1) { + let { data: comments } = await octokit.issues.listComments({ + owner, + repo, + issue_number: number, + per_page: 100, + page, + }); + if (comments.length >= 100) { + comments = comments.concat(await listComments(page + 1)); + } + return comments; + } + + const commentList = await listComments(); core.info(`Actions: [find-comments][${number}] success!`); let comments = []; - res.data.forEach(item => { + commentList.forEach(item => { const a = commentAuth ? item.user.login === commentAuth : true; const b = bodyInclude ? item.body.includes(bodyInclude) : true; if (a && b) {