我正在尝试在我的 GitHub 应用程序中实施 Checks。我的应用程序是用 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
上面的代码是否足以创建检查test-check-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:结束