Try to update earliest matching comment #37
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Signed-off-by: dkwon17 [email protected]
Context
In the case of https://github.com/eclipse-che/che-dashboard, where the GitHub action is added to the repository like so:
Whenever a pull request is made, and whenever a new commit has been made to the pull request branch, duplicate
Click here to review and test in web IDE:
comments are being made (for example see: eclipse-che/che-dashboard#826)The GitHub action tries to prevent this issue by trying to detect if a comment has already been made, before it decides to make a new comment or not.
The reason why there are duplicate comments in the case of che-dashboard repo, is because the comments are being made by che-bot which is a regular user. Currently, GitHub action comments are not detected, unless they are made by a bot, see #29.
What does this PR do
This PR takes the simple stupid approach of just trying to edit the earliest match of the comment string if needed, regardless of if the comment author is a bot or not.
In most cases, the earliest comment which matches the comment string, would be the comment created using the GitHub action anyways.
Why not try to determine the author of the comment by checking the current
github_token
specified to the GH action?The token may not have get-user permissions. For example, the
secrets.GITHUB_TOKEN
token (which is the default token for GH actions) does not have this permission.Related Issue(s)
#31
Checklist
Changes made