unsplash/comment-on-pr

Don't fail if no PR Exists (optionally?)

WCByrne opened this issue · 2 comments

I have this running on all push events which works great when pushing to a branch with a PR but if there is no PR I just want it to skip. This of course happens on every PR merge where this is a push to master. In my case I still want to run the rest of my action but skip the last step which is posting a comment.

The only option I see to do this cleanly would be to use the if for the step but that would require somehow duplicating the logic this action is doing to find an associated PR.

Would it make sense to exit(0) for that case? If that would cause issues for existing users of this action, maybe it could be optional.

I need something similar, see #16

dlime commented

I've used this condition as workaround: github.event_name == 'pull_request'

      - name: comment PR
        uses: unsplash/comment-on-pr@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          msg: "Check out this message!"
        if: github.event_name == 'pull_request'