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

Workflow context when triggered by issue_comment

Solved! Go to Solution.

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.

 

Peter

3 Replies
Solution
GitHub Staff
Message 2 of 4

Re: Workflow context when triggered by issue_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.

Copilot Lvl 3
Message 3 of 4

Re: Workflow context when triggered by issue_comment

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.

Copilot Lvl 2
Message 4 of 4

Re: Workflow context when triggered by issue_comment

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

github.event.pull_request

 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.