如何在监听`pull_request`事件的nodejs github probot中检索PR号

How to retrieve the PR number in nodejs github probot listening on `pull_request` event

我使用 nodejstypescript 创建了一个 GitHub probot 应用程序。我正在收听 pull_request 活动。如何从 probot context 对象中检索 pr_number

以下是intex.ts

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

  })
}

您感兴趣的字段在回调中 context.payload

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

这与 GitHub Webhook 事件页面中列出的负载匹配:https://developer.github.com/webhooks/#events

您对 pull_request 有效负载感兴趣,可在此处找到:https://developer.github.com/v3/activity/events/types/#pullrequestevent

pull_request.number是您需要的相关信息:

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