Skip to content

Commit

Permalink
action.yml: use graphql to delete comment
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Nov 29, 2023
1 parent f3be07f commit 86744d7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
repo: context.repo.repo,
prnum: context.issue.number }));
var query = `query($owner:String!, $name:String!, $prnumber:Int!) {
const query = `query($owner:String!, $name:String!, $prnumber:Int!) {
repository(owner:$owner, name:$name) {
pullRequest(number:$prnumber) {
comments(last: 100) {
Expand All @@ -64,17 +64,16 @@ runs:
}
const messages = (await github.graphql(query, variables)).repository.pullRequest.comments.nodes;
const deleteQuery = `mutation {
deleteIssueComment(input:{$id:ID!}) {
clientMutationId
}
}`
for (var i = 0; i < messages.length; i++) {
if (messages[i].body.includes(watermark)) {
console.log(messages[i])
await github.request('DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}', {
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: messages[i].id,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
await github.graphql(deleteQuery, {id: messages[i].id});
}
}
Expand Down

0 comments on commit 86744d7

Please sign in to comment.