actions-cool / maintain-one-comment

📌 Maintain just one comment in Issue and PR by GitHub Action.
MIT License
34 stars 4 forks source link

Avoid deleting a comment that was just created before and prevent creating empty comments #5

Closed thyandrecardoso closed 1 year ago

thyandrecardoso commented 1 year ago

Hi!

This PR tentatively changes the behavior of delete so that we only delete the comments that were there previously and then stop, instead of creating a comment and deleting it. Also, it avoids creating a comment with an empty body.

I was looking into using this action and noticed that, if delete = true the action tries to delete all comments found including the one that might have been created just before: https://github.com/actions-cool/maintain-one-comment/blob/de04bd2a3750d86b324829a3ff34d47e48e16f4b/src/main.js#L150-L156

Shouldn't we be ignoring the new comment here, or is there a use case for creating and immediately deleting the comment?

Related to this is also the behavior of an empty body. According to the readme: When has 1 comment, and no body input will delete this filter comment. From this and from what I sense is the overall intent of this action, I would assume that an empty body would never trigger a comment, but: https://github.com/actions-cool/maintain-one-comment/blob/de04bd2a3750d86b324829a3ff34d47e48e16f4b/src/main.js#L79-L86

In my specific case, what I am looking for is something that always comments on the same "comment" according to a given input. And, when that input is empty, I want the comment to disappear.

I can achieve that behavior with this action by, for example, conditionally setting delete according to the length of the body. However, that creates a flow of create a comment with an empty body -> delete previously created comment. One annoying thing about this is that GitHub may send you a notification about a new comment which, when you click on the notification, does not exist.

Do these changes make sense?