名称: github
描述: "使用 gh CLI 与 GitHub 交互。通过 gh issue、gh pr、gh run 和 gh api 处理议题、拉取请求、CI 运行和高级查询。"
使用 gh CLI 与 GitHub 交互。若不在 git 目录中,请始终指定 --repo owner/repo,或直接使用 URL。
检查 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)"'