用途
GitHub Skill 用于通过 gh CLI 与 GitHub 进行交互,覆盖 issue、PR、CI 运行以及高级查询等操作。当用户提出相关需求时使用。
在非 git 目录中操作时,始终指定 --repo owner/repo,或直接使用 URL。
主要能力
Pull Requests
检查 PR 的 CI 状态:
gh pr checks 55 --repo owner/repo
列出最近的工作流运行:
gh run list --repo owner/repo --limit 10
查看某次运行并了解哪些步骤失败:
gh run view <run-id> --repo owner/repo
仅查看失败步骤的日志:
gh run view <run-id> --repo owner/repo --log-failed
调试 CI 失败
按以下顺序调查失败的 CI 运行:
- 检查 PR 状态——确认哪些检查失败:
gh pr checks 55 --repo owner/repo
- 列出最近的运行——找到相关的 run ID:
gh run list --repo owner/repo --limit 10
- 查看失败的运行——了解哪些作业和步骤失败:
gh run view <run-id> --repo owner/repo
- 获取失败日志——得到失败步骤的详细输出:
gh run view <run-id> --repo owner/repo --log-failed
用于高级查询的 API
gh api 命令可用于访问其他子命令无法提供的数据。
获取包含特定字段的 PR:
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
JSON 输出
大多数命令支持 --json 以输出结构化结果。可以使用 --jq 进行过滤:
gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
使用方式
通过 gh CLI 执行上述命令。在非 git 目录中操作时,始终指定 --repo owner/repo,或直接使用 URL。
适用场景
- 检查 PR 的 CI 状态
- 列出最近的工作流运行
- 查看某次运行中哪些步骤失败
- 仅获取失败步骤的日志
- 调试 CI 失败
- 使用
gh api进行高级查询 - 以 JSON 格式输出并过滤结果
限制
资料中未提供关于收费、价格、平台支持范围或效果保证的信息。