Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to update earliest matching comment #37

Merged
merged 1 commit into from
Jul 14, 2023

Conversation

dkwon17
Copy link
Collaborator

@dkwon17 dkwon17 commented Jun 13, 2023

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:

on:
  pull_request_target:
    types: [opened, synchronize]

jobs:
  add-link:
    runs-on: ubuntu-22.04
    steps:
      - name: Web IDE Pull Request Check
        id: try-in-web-ide
        uses: redhat-actions/try-in-web-ide@v1
        with:
          github_token: ${{ secrets.CHE_BOT_GITHUB_TOKEN }}

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

  • This PR includes a documentation change
  • This PR does not need a documentation change

  • This PR includes test changes
  • This PR's changes are already tested

  • This change is not user-facing
  • This change is a patch change
  • This change is a minor change
  • This change is a major (breaking) change

Changes made

@dkwon17 dkwon17 requested a review from ibuziuk as a code owner June 13, 2023 18:17
@github-actions github-actions bot added CRDA Scan Approved CRDA scan approved by a collaborator CRDA Scan Passed CRDA found no vulnerabilities labels Jun 13, 2023
@github-actions github-actions bot added CRDA Scan Passed CRDA found no vulnerabilities and removed CRDA Scan Passed CRDA found no vulnerabilities labels Jun 29, 2023
@github-actions github-actions bot added CRDA Scan Passed CRDA found no vulnerabilities and removed CRDA Scan Passed CRDA found no vulnerabilities labels Jul 14, 2023
@dkwon17 dkwon17 merged commit d4d3150 into redhat-actions:main Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CRDA Scan Approved CRDA scan approved by a collaborator CRDA Scan Passed CRDA found no vulnerabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants