用途:通过 gh CLI 与 GitHub 交互,覆盖议题(issues)、拉取请求(PRs)、CI 运行(runs)以及高级 API 查询等场景。
主要能力与用法:
- 拉取请求与 CI:检查 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 用于访问其他子命令未提供的数据,例如获取 PR 指定字段: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)"'。
限制与注意事项:资料明确要求,当不在 git 目录中时必须始终指定 --repo owner/repo,或直接使用 URL。其余关于认证、权限、费用或平台要求暂未提供。