我正在尝试在我的 GitHub 应用程序中实施检查。我的应用程序是用 probot 构建的。
我只是无法实施检查。我尝试过浏览演示 ruby 示例的文档,其中包括几种不同的设置(不确定 probot 是否需要)。
我只是对那里的例子感到困惑。
下面是我的 index.js 中的代码:
app.on('check_suite.requested', async context =>{
console.log('************------------ check suite requested')
await context.github.checks.create({
mediaType:'application/vnd.github.antiope-preview+json',
name : 'test-check-1',
head_sha: context.payload.check_suite.after,
conclusion: "success"
})
})
我收到以下错误
ERROR probot: Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
错误日志抱怨index.js:24:35,这正是create
行中的方法await context.github.checks.create
上面的代码足以创建检查吗测试检查-1或者我还需要处理其他事情吗?我已经有了“合并前需要通过状态检查”在我的存储库的分支保护设置下启用了选项。
该部分显示抱歉,我们上周找不到此存储库的任何状态检查。
不知道如何连接一切。
编辑1:开始
下面是包含 @OscarDOM 建议的必需参数后的代码:--
app.on('check_suite.requested', async context =>{
console.log('*****check suite requested*****')
context.github.checks.create({
owner:context.payload.repository.owner,
repo:context.payload.repository.name,
mediaType:'application/vnd.github.antiope-preview+json',
name : 'test-check-1',
head_sha: context.payload.check_suite.after,
conclusion: "success"
})
})
不幸的是,我仍然在完全相同的行和列处遇到相同的错误。
编辑1:结束
编辑2:开始
以下是对 mediaType 参数进行更正后的最终工作代码:
请注意,我还必须纠正一个错误,那就是值所有者参数。正确的方法是指定 context.payload.repository.owner.login 这是我最近学到的这个 StackOverflow 帖子
app.on('check_suite.requested', async context =>{
console.log('*****check suite requested*****')
context.github.checks.create({
owner:context.payload.repository.owner.login,
repo:context.payload.repository.name,
mediaType: { previews: ['antiope']},
name : 'test-check-1',
head_sha: context.payload.check_suite.after,
conclusion: "success"
})
})
编辑2:结束