无法使用 GitHub API 重新请求检查运行

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

因此,我列出了来自特定参考的所有检查运行,并选择第一个,然后要求重新运行(检查运行失败):

const result = await octokit.checks.listForRef({
    owner: organization.providerLogin,
    repo: repository.name,
    ref: pullRequest.ref,
  });
const checkRun = result.data.check_runs[0]
await octokit.checks.rerequestRun({
    owner: organization.providerLogin,
    repo: repository.name,
    check_run_id: checkRun.id,
  });

但是我收到此错误

Invalid check_run_id '16889946523'
,所以我现在正在寻求一些帮助,提前谢谢您。

github github-api octokit
1个回答
0
投票

GitHub 文档中的命名似乎有点混乱。我刚刚也遇到这个问题了

我通过使用操作作业重新运行端点而不是检查运行重新请求来修复它。

正确终点:

POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun

所以你的代码应该是这样的(我没有测试它,只是用 TypeScript 类型编写的):

const result = await octokit.rest.checks.listForRef({
  owner: organization.providerLogin,
  repo: repository.name,
  ref: pullRequest.ref,
});
const checkRun = result.data.check_runs[0]
await octokit.rest.actions.reRunJobForWorkflowRun({
  owner: organization.providerLogin,
  repo: repository.name,
  job_id: checkRun.id,
});
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.