如何在nodejs github probot中检索“pull_request”事件中的PR号

问题描述 投票:0回答:1

我使用GitHub probotnodejs创建了一个typescript应用程序。我正在听pull_request事件。如何从probot pr_number对象中检索context

以下是intex.ts中的代码

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

  })
}
node.js typescript github-api probot
1个回答
1
投票

你感兴趣的领域是回调中的context.payload

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

这与GitHub Webhook Events页面中列出的有效负载相匹配: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
  })
}
© www.soinside.com 2019 - 2024. All rights reserved.