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) => {
})
}
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
})
}