fix: list comment page lost in [find-comments] (#66)

* fix: list comment page lost in [find-comments]

* add changelog
This commit is contained in:
xrkffgg
2021-03-21 20:32:11 +08:00
committed by GitHub
parent 89884a3a50
commit d82909b31d
13 changed files with 145 additions and 117 deletions

22
dist/index.js vendored
View File

@@ -7802,14 +7802,10 @@ async function doCloseIssues(owner, repo, labels) {
}
async function doFindComments(owner, repo, issueNumber) {
const res = await octokit.issues.listComments({
owner,
repo,
issue_number: issueNumber,
});
const commentList = await listComments(owner, repo, issueNumber);
core.info(`Actions: [find-comments][${issueNumber}] success!`);
let comments = [];
res.data.forEach(item => {
commentList.forEach(item => {
const a = commentAuth ? item.user.login === commentAuth : true;
const b = bodyIncludes ? item.body.includes(bodyIncludes) : true;
if (a && b) {
@@ -7829,6 +7825,20 @@ async function doFindComments(owner, repo, issueNumber) {
core.info(`out-comments: ${JSON.stringify(comments)}`);
}
async function listComments(owner, repo, issueNumber, page = 1) {
let { data: comments } = await octokit.issues.listComments({
owner,
repo,
issue_number: issueNumber,
per_page: 100,
page,
});
if (comments.length >= 100) {
comments = comments.concat(await listComments(page + 1));
}
return comments;
}
async function doLockIssues(owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, issueState);