Fix: Ignore other users' comments (#332)

Make findPreviousComment only return comments made by the current user
(usually github-actions[bot])
This commit is contained in:
Rob Cowsill 2021-06-14 19:25:28 +01:00 committed by GitHub
parent 2020b5bc34
commit 65b0a353cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 309 additions and 283 deletions

View file

@ -14,12 +14,15 @@ export async function findPreviousComment(
issue_number: number,
header: string
): Promise<{body?: string; id: number} | undefined> {
const {viewer} = await octokit.graphql("query { viewer { login } }")
const {data: comments} = await octokit.rest.issues.listComments({
...repo,
issue_number
})
const h = headerComment(header)
return comments.find(comment => comment.body?.includes(h))
return comments.find(
comment => comment.user?.login === viewer.login && comment.body?.includes(h)
)
}
export async function updateComment(
octokit: InstanceType<typeof GitHub>,