Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete multiple issue/PR comments via the GitHub API

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.

like image 724
dan1st Avatar asked Dec 02 '19 15:12

dan1st


People also ask

How do I remove a comment from a pull request GitHub?

Steps to delete a comment In the upper-right corner of the comment, click , then click Delete.

How do you resolve PR comments?

Resolving conversations You can resolve a conversation in a pull request if you opened the pull request or if you have write access to the repository where the pull request was opened. To indicate that a conversation on the Files changed tab is complete, click Resolve conversation.


1 Answers

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 :(

like image 194
Alexandr Shurigin Avatar answered Nov 15 '22 07:11

Alexandr Shurigin