4

I want to delete multiple PRs/issues comments at once with GitHub Actions over the GitHub API.

Is there a way to do this without showing the delete message multiple times like the following image?

delete message 4 times

For example, I thought there may be a way to delete multiple issue/pull request review comments with one request that shows a message like <user> deleted n comments from <users whose comments have been deleted>?

Currently, I am deleting messages using the following curl command in a loop:

echo "$ids" | while read -r id; do
    curl -X "DELETE" -s -H "authorization: token $GITHUB_TOKEN" -H "User-Agent: Actions-<username>/<reponame>" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/<username>/<reponame>/issues/<issue number>/comments/$id"
done

If it is a pull request, I use pulls with instead of issues.

I also think that there is a rate limit preventing the deletion of that many commands in such a short time.

See the docs for deleting an issue and a pull request comment.

[Context]

I want to create a command that clears multiple messages at once. If somebody enters /clear 5 for example, the latest 5 messages will be deleted.

dan1st
  • 6,537
  • 6
  • 18
  • 44
  • Do you need to do it from a GitHub action? Pull requests won't allow you modify the repository; issues will, but maybe it's better if it's done directly from a client. – jjmerelo Dec 04 '19 at 16:51
  • Yes, I only want to delete Issue/PR comments. – dan1st Dec 04 '19 at 16:56
  • then it's probably better if you just run a loop and use the curl client or any other. – jjmerelo Dec 04 '19 at 17:00
  • The problem is that I get so many messages that are displaying that the bot deleted a message. – dan1st Dec 04 '19 at 17:01
  • I think we need more information here. Are you deleting something from a github action, and that action also causes another deletion? Can you show that action that's been triggered? – jjmerelo Dec 04 '19 at 17:06
  • The action is triggered by a issue/pr review comment with the content `/clear ` and deletes messages – dan1st Dec 04 '19 at 17:13

1 Answers1

0

No, you can't do it. It is a core feature from Github to create a timeline event on any action (like push, comment, rebase, merge, etc). That's a standard placeholder.

https://help.github.com/en/github/building-a-strong-community/managing-disruptive-comments#deleting-a-comment

Also, it looks like Github doesn't support BATCH operations currently.

So, NO and NO at the moment :(

Alexandr Shurigin
  • 3,681
  • 1
  • 11
  • 23