peter-evans/find-comment

if it is possible to find multiple matches?

Closed this issue · 2 comments

Hi, I wonder if this action could find multiple matches? From the readme, it seems that it only supports first and last matches?

find-comment/src/find.ts

Lines 51 to 75 in dea9995

if (inputs.direction == 'first') {
for await (const {data: comments} of octokit.paginate.iterator(
octokit.rest.issues.listComments,
parameters
)) {
// Search each page for the comment
const comment = comments.find(comment =>
findCommentPredicate(inputs, comment)
)
if (comment) return comment
}
} else {
// direction == 'last'
const comments = await octokit.paginate(
octokit.rest.issues.listComments,
parameters
)
comments.reverse()
const comment = comments.find(comment =>
findCommentPredicate(inputs, comment)
)
if (comment) return comment
}
return undefined
}

Looks like we can change this to return all the matches? Is that a json format?

Hi @xihajun

The goal of this action is to find a specific comment, not a list of comments. The main issue with finding multiple comments is returning the output.

I don't think this is something that I want to try and support in this action. My suggestion would be to call the GitHub API yourself for this use case using github-script.