0

I have created a GitHub probot app using nodejs and typescript. I am listening on pull_request event. How do I retrieve pr_number from the probot context object?

following is the code in intex.ts

export = (app: Application) => {
  app.on('pull_request', async (context) => {

  })
}
Shravan Ramamurthy
  • 3,896
  • 5
  • 30
  • 44

1 Answers1

2

The field that you're interested in is context.payload inside the callback:

export = (app: Application) => {
  app.on('pull_request', async (context) => {
    const payload = context.payload
    // ...
  })
}

This matches the payloads listed in the GitHub Webhook Events page: https://developer.github.com/webhooks/#events

You're interested in the pull_request payload which can be found here: https://developer.github.com/v3/activity/events/types/#pullrequestevent

And pull_request.number is your relevant piece of information you need:

export = (app: Application) => {
  app.on('pull_request', async (context) => {
    const payload = context.payload
    const number = payload.pull_request.number
  })
}
Brendan Forster
  • 2,548
  • 1
  • 24
  • 32