我使用nodejs
和typescript
创建了一个GitHub probot
应用程序。我正在收听pull_request
活动。如何从机器人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
})
}