Skip to content

Commit

Permalink
fix: list comments miss.
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Mar 19, 2021
1 parent 4b10a6d commit ed4d3a5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.2.1

`2021.03.19`

- fix: list comments miss.

## v1.2.0

- feat: add outputs `comment-id`.
Expand Down
22 changes: 16 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 16 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ed4d3a5

Please sign in to comment.