Filter Pull request comments from issue_comment

Hello all,
I wanted to run a job on pull request comment basis for which I have to filter pull_request comment from issue_comment for running a job. I tried this but not able to filter it for only pull request comments it still works with both.

name: CI-test
on:
  issue_comment:
    types: [created]

jobs:
  tests:
    if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run-e2e')
    runs-on: ubuntu-latest
    steps:

Can I get some help on this please?

1 Like

I tried your workflow yml in my side, it will be triggered by both pull request comment and issue comment. But the if conditional will return false when adding comment in issue. And the job “tests” will be skipped .


Is this your expected behavior? If not, could you please share me a detail description of your requirement?

2 Likes

Thanks, @yanjingzhu
This is one way I could get the action triggered on a pull request comment basis, But, Is there a way to achieve the same without having any entry(skipped) on the Actions history. i.e there should not be any entry for issue comments.

Sorry to tell you that there is no other ways to filter pull request comments from issue_comment.
Pull requests is the subset of issues. According to the API : https://developer.github.com/v3/issues/comments/ , creating comments on issues and pull requests will both create an issue_comment type webhook event.
So I am afraid that using if conditional to filter the html_url is the only workaround for your scenario.

1 Like

Very disappointing to say the least. This heavily clutters the actions log with the hundreds of runs that are skipped because it is an issue and not a PR. This should definitely be handled in the trigger statements. Why not allow for more complicated “on:” statements/events?