Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 5

Phrase triggering of workflows in pull requests

Solved! Go to Solution.

Hi,

I'm trying to duplicate behaviour of Jenkins ghprb plugin, which allows you to start a Jenkins job by posting a trigger phrase in a pull request comment.

 

I think that the closest event to use in Actions would be 

pull_request_review_comment

but I didn't manage to use it so far.

Does anyone know how to do that?

Cheers!

4 Replies
Copilot Lvl 2
Message 2 of 5

Re: Phrase triggering of workflows in pull requests

I have the same issue.

 

I'm creating actions these days.

https://github.com/tyankatsu0105/message-to-slack-from-github/pull/1

But I can't find a solution to the trigger for PR comment. 

 

I found this page. https://developer.github.com/v3/guides/working-with-comments/#pull-request-comments

According to this page, PR comments use issues API.

I tried adding `issue_comment` on `on`.

But not working...

Copilot Lvl 2
Message 3 of 5

Re: Phrase triggering of workflows in pull requests

OK.

I understand.

PR message's eventName is `issue_comment`.

So you can check `Mention Slack` jobs's log in here.

https://github.com/tyankatsu0105/message-to-slack-from-github/commit/9a72de4917a22696b0ece5cd6ca9c11...

Copilot Lvl 3
Message 4 of 5

Re: Phrase triggering of workflows in pull requests

Having the same issue.  I've created a small workflow that just prints the comment but it never fires when I comment on the pull request containing this workflow.  Even tried covering all the bases for the different events but no joy.

 

Do we somehow have to register the workflow to fire on PR comments some other way?

 

name: terraform-staging-apply

on: 
  issue_comment: 
    types: [created, edited]
  pull_request_review_comment: 
    types: [created, edited]
  pull_request_review: 
    types: [submitted, edited, dismissed]
  issues: 
    types: [opened, closed]

jobs:
  terraform-apply:
    name: Terraform Apply
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@1.0.0
        with:
          submodules: 'true'
          token: ${{ secrets.PAT }} # Needed for private submodules

      - uses: actions/github-script@0.2.0
        with:
          github-token: ${{github.token}}
          script: |
            const body = context.payload.pull_request.body.toLowerCase()
            console.log("Detected comment: " + body)
Solution
Copilot Lvl 3
Message 5 of 5

Re: Phrase triggering of workflows in pull requests

Found the issue in another thread:

 

https://github.community/t5/GitHub-Actions/on-issue-comment-events-are-not-triggering-workflows/m-p/...

 

In short, the workflow triggering on issue comments MUST be in master