unsplash / comment-on-pr

A GitHub Action to comment on the relevant open PR when a commit is pushed.
MIT License
150 stars 84 forks source link

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

Open WCByrne opened 4 years ago

WCByrne commented 4 years ago

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.

Vadorequest commented 4 years ago

I need something similar, see #16

dlime commented 4 years ago

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'