Hey Fer,

I'm not 100% sure I follow what you're trying to do, but one approach you
could take is to gate everything off of an if like:

` if {{ (github.event.issue.pull_request && github.event.comment &&
contains(github.event.comment.body,
"PHRASE")) || !github.event.comment }}

Basically, that's doing: `if (<this is a PR> && <this is a comment> && <the
comment contains the phrase>) || <this is not an issue comment>`

I haven't tested it so it might be a little off syntactically, but I
believe that should generally do what you're trying to do. FWIW, you might
find it helpful to dump the context with an action like this
<https://github.com/crazy-max/ghaction-dump-context> in a test repo - that
will show you exactly what is available in the github context for each kind
of event so that you can use them accordingly.

Thanks,
Danny

On Thu, Jul 14, 2022 at 3:20 PM Fer Morales Martinez <
fernando.mora...@wizeline.com> wrote:

> Hello everyone!
>
> As part of the migration of the precommit and postcommit jobs from jenkins
> over to github actions, we're trying to implement the *trigger phrase*
> functionality.
> Our first approach was to use issue_comment
> <https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment>
> One problem we noticed after testing is that it looks like issue_comment
> is mutually exclusive with the other events. For example, given the
> following flow
>
> name: Java Tests
> on:
>   schedule:
>     - cron: '10 2 * * *'
>   push:
>     branches: ['master', 'release-*']
>   pull_request:
>     branches: ['master', 'release-*']
>     paths: ['sdks/java/**', 'model/**', 'runners/**', 'examples/java/**',
>             'examples/kotlin/**', 'release/**', 'buildSrc/**']
>   issue_comment:
>   types: [created]
>
> jobs:
>   pr_commented:
>       # This job only runs for pull request comments
>       name: PR comment
>         if: ${{ github.event.issue.pull_request }}
>     runs-on: ubuntu-latest
>     steps:
>        - run: |
>               echo A comment on PR $NUMBER
>         env:
>            NUMBER: ${{ github.event.issue.number }}
>
>   issue_commented:
>     # This job only runs for issue comments
>     name: Issue comment
>     if: ${{ !github.event.issue.pull_request }}
>     runs-on: ubuntu-latest
>     steps:
>       - run: |
>           echo A comment on issue $NUMBER
>         env:
>           NUMBER: ${{ github.event.issue.number }}
>
> the flow will get kicked off but upon validating the if conditional,
> neither job will run since the github.event.issue.pull_request parameter is
> not present.
>
> Another caveat is that we'd have to populate with an if statement every
> job we wanted to execute by way of a trigger phrase.
>
> Does someone have experience with this kind of work? Has someone
> implemented trigger phrases in github actions?
>
> Thanks!
>
>
>
>
>
>
>
>
>
> *This email and its contents (including any attachments) are being sent
> toyou on the condition of confidentiality and may be protected by
> legalprivilege. Access to this email by anyone other than the intended
> recipientis unauthorized. If you are not the intended recipient, please
> immediatelynotify the sender by replying to this message and delete the
> materialimmediately from your system. Any further use, dissemination,
> distributionor reproduction of this email is strictly prohibited. Further,
> norepresentation is made with respect to any content contained in this
> email.*

Reply via email to