| 名称 | github |
| 描述 | “使用 gh CLI 与 GitHub 交互。使用 gh issue、gh pr、gh run 和 gh api 来处理 issues、PRs、CI runs 和高级查询。” metadata: { “otto”: { “emoji”: “🐙”, “requires”: { “bins”: [“gh”] }, “install”: [ { “id”: “brew”, “kind”: “brew”, “formula”: “gh”, “bins”: [“gh”], “label”: “安装 GitHub CLI (brew)”, }, { “id”: “apt”, “kind”: “apt”, “package”: “gh”, “bins”: [“gh”], “label”: “安装 GitHub CLI (apt)”, }, ], }, } |
GitHub 技能
使用 gh CLI 与 GitHub 交互。当不在 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
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)"'