Workflow context when triggered by issue_comment

Hi!  I am writing a simple bot that will run status checks when a comment (something like “@mybot build”) is made on a pull request.

I notice that when a workflow is triggered by issue_comment as the result of a comment being made on a pull request, github.ref is always refs/heads/master.  What I really want is for the context to be the branch that the pull request is on so the status checks in the pull request will update accordingly.

Is this a bug?  If this is expected behavior, then I guess I will need to use the Statuses API explicitly to get the pull request to update properly in response to a check being run as the result of a comment.



Comments on issues and pull requests will have the ref set to the default branch.  However, you should be able to inspect the full github event context for the information about the pull request in question.

I think that what you’re looking for is github.event.issue.pull_request and github.event.issue.number.

1 Like

Yeah, thanks for the reply.  I can indeed get the pull request number from the event, but I can’t get the PR ref directly from the event which means I need to do an API call to figure out what branch to checkout.  Complicates the workflow but it’s doable.

We have a similair issue. It would be really great to have something like


 that containes all the information about pull request that was commented including head_ref and base_ref
Performing additional api call inside workflow and parsing it is a bit messy imo.


Trying to set this up myself now. Did you ever get it working?

This is what I tried,

- uses: actions/checkout@v2
- run: |
       git fetch origin +refs/pull/${{ github.event.issue.number }}/merge
       git checkout FETCH_HEAD
1 Like