GitHub Actions: get the PR ID that started it?

Hi all!

I’m starting with GitHub Actions, and I wanted to send a Slack notification when a PR review was submitted. This is the workflow I’m using:

workflow "Notify PR reviews" {
  on = "pull_request_review"
  resolves = ["GitHub Action for Slack"]

 action "On review submission" {
  uses = "actions/bin/filter@c6471707d308175c57dfe91963406ef205837dbd"
  args = "action submitted"

 action "GitHub Action for Slack" {
  uses = "Ilshidur/action-slack@5b3a58f5e0ff655ca9c17a22516efdf9d0de36bf"
  needs = ["On review submission"]
  secrets = ["SLACK_WEBHOOK"]
  args = "A new PR review was submitted!"

I checked the available environment variables, but I can’t seem to find any that returns this info. Am I missing something?


Hi @mrcasals!

You should be able to get this information by looking at the file located at the environment variable GITHUB_EVENT_PATH, you can find more information on that here:

This should contain information about the Pull Request that has triggered your action.

If I’m misreading anything, let me know!

1 Like

@mrcasalsCan you post your use case here?

I’m working on creating example workflows similar to what you’re describing.

Done, thanks!

Maybe it’s better if we use an action to set some env variables based on the GITHUB_EVENT_PATH contents, and use your Slack image to send the contents of those variables, as the docs say that “any action can create […] environment variables”:

Hi @nickvanw! Thanks for your reply!

I didn’t realize the GITHUB_EVENT_PATH pointed to a file in the filesystem, guess I read that section diagonally. Thanks! I don’t understand what the “payload of the event” is, though. How can I debug what this file contains? I might be missing something :frowning:

I see that “any action can create […] environment variables”, as per the link you posted. Could we create an action that sets env variables based on the contents of the file, and then use those variables as args for the action that sends the message? 

@mrcasalsI think we’re thinking along the same lines. I responded to your comment on that issue. If you’d like, maybe close this ticket here and we can continue collaborating on the issue thread?

Hey @mrcasals!

It looks like you’re already working with @abinoda, but if you look inside of that file you’ll find that it matches the same format that’s documented for our webhooks ( - so if you’re looking at PRs, for example, it should follow the same format here:

From there, you should be able to parse it as JSON and extract the data yourself. It looks like @abinoda is working on a generic way to extract these, but you should be able to use your language of choice to parse the information you need from that file. 

1 Like

I have just started experimenting with this…
Could you please point me to a sample of this?

action “GitHub Action for Slack” {
uses = “Ilshidur/action-slack@f37693b4e0589604815219454efd5cb9b404fb85”
secrets = [“SLACK_WEBHOOK”]
args =

I want a link to the PR in the args