用途:在 GitHub 上完成日常协作操作,基于 gh 命令行工具访问仓库的 issue、Pull Request、CI 工作流运行与更底层的 API 数据。
主要能力:
- 拉取请求:检查某个 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。
- 高级查询:gh api 用于获取其他子命令未覆盖的数据,例如 gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'。
- 结构化输出:多数命令支持 --json,配合 --jq 过滤,例如 gh issue list --repo owner/repo --json number,title --jq '.[] | "(.number): (.title)"'。
使用方式:调用 gh 的子命令 gh issue、gh pr、gh run、gh api;当不在 git 目录中时始终指定 --repo owner/repo,或直接使用 URL。
适用场景:仓库协作者查看 PR 检查结果、排查 CI 失败、批量查询 issue 与 PR 字段。
限制:资料未说明安装方式、认证配置、权限范围、速率限制及平台支持情况。