mshick / add-pr-comment

uses: mshick/add-pr-comment@v2
MIT License
196 stars 54 forks source link

Removing a comment #108

Open estahn opened 1 year ago

estahn commented 1 year ago

I run this as part of a CI pipeline and add a PR comment if there is a failure. I would like to remove the PR comment entirely if the steps succeed.

Maybe an attribute remove: true or similar.

alex-inv commented 1 year ago

Our use-case for add-pr-comment action is to add a comment to the PR if a specific label is missing. When the label is finally added, would be really nice if we could automatically remove the now obsolete comment 🙏

mshick commented 8 months ago

I think this could actually be accomplished by a minor fix to the current behavior. If you only wanted a message to print when you have a failure, and you've set a message-failure override like below, then the action example here would actually cause an error:

      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          message-failure: |
            Uh oh!

What I might do instead is set the action to remove an existing message when no message input is found, rather than error out which I do now.

FWIW, maybe this functionality below is acceptable? You'd set your failure message, and it would be updated with a success message on the run that worked for you?

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          message: |
            **Howdie!**
          message-failure: |
            Uh oh!