feat: fetch data for prs that need retest
This commit is contained in:
23
src/lib/get_comments.mjs
Normal file
23
src/lib/get_comments.mjs
Normal file
@@ -0,0 +1,23 @@
|
||||
export default async function getEvents(repo, { body, actor } = {}) {
|
||||
const { items: events } = await repo.events.fetch();
|
||||
|
||||
return events
|
||||
.map(comment => {
|
||||
// only comments created by specific user
|
||||
if (comment.type !== 'IssueCommentEvent') return false;
|
||||
if (comment.payload.action !== 'created') return false;
|
||||
if (comment.actor.login !== actor) return false;
|
||||
if (body && !body.test(comment.payload.comment.body)) return false;
|
||||
|
||||
return {
|
||||
id: comment.id,
|
||||
number: comment.payload.issue.number,
|
||||
owner: comment.payload.issue.user.login,
|
||||
labels: comment.payload.issue.labels.map(label => label.name),
|
||||
comment_id: comment.payload.comment.id,
|
||||
comment_author: comment.payload.comment.user.login,
|
||||
comment_body: comment.payload.comment.body,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
Reference in New Issue
Block a user