首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Probot check-js拉取请求

Probot check-js拉取请求
EN

Stack Overflow用户
提问于 2020-07-17 12:44:16
回答 1查看 216关注 0票数 1

我正在使用nodeJS (ProBot)为github构建一个代码审查应用程序。

我试图从为获取相关文件和运行测试而创建的check_suite中获取pull_request数据,但context.payload.pull_request是空的。

我还尝试了监听事件pull_request.created,那里有我需要的数据,但是context.github.checks.update() / context.github.checks.create()不会更新检查的状态,并且永远保持为in_progress。

下面是我的代码:

代码语言:javascript
复制
module.exports = app => {
app.on([
'check_suite.requested',
'check_run',
'pull_request.opened', 
], check)
async function check (context) {
const startTime = new Date()

if (context.payload.check_suite) {
  const { head_branch: headBranch, head_sha: headSha } = context.payload.check_suite

   return context.github.checks.create(context.repo({
    name: 'SoftaCheck',
    head_branch: headBranch,
    head_sha: headSha,
    status: 'in_progress',
    started_at: startTime,
  }))
}

const payload =  {head_branch: context.payload.pull_request? context.payload.pull_request.base.ref : context.payload.check_run.pull_requests[0].base.ref ,head_sha : context.payload.pull_request? context.payload.pull_request.base.sha : context.payload.check_run.pull_requests[0].base.sha }

const { head_branch, head_sha } = payload

if (context.payload.pull_request) {
    
   //some async code here in order to decide conclusion...

   context.github.checks.create(context.repo({
     name: 'SoftaCheck',
     head_branch,
     head_sha,
     status: 'completed',
     conclusion:'success'
     started_at: startTime,
   }))

}

}

//构建应用的更多信息: // https://probot.github.io/docs/

//要使您的应用程序在GitHub上运行,请参阅: // https://probot.github.io/docs/development/ }

EN

回答 1

Stack Overflow用户

发布于 2020-07-22 04:59:48

我不确定您是如何实现check.create方法的。相反,您应该传入repo名称。

需要注意的几件事:

您的GitHub应用程序必须具有check:write permission

  • 另外,请确保您的checks.create方法具有required properties(属性是必需的)。例如,在您的案例中缺少所有者属性。

早些时候,我遇到了somewhat similar issue

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62947254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档