SuperAPI AI 工具集

github

部署与运维

查看项目

更新于 10-16 05:33

技能介绍

用途

GitHub 技能用于通过 gh CLI 与 GitHub 仓库、Issue、PR 和 CI 进行交互,帮助在命令行中完成常见的 GitHub 操作。

主要能力

  • 检查 PR 状态、审查或合并就绪情况
  • 查看 CI/工作流运行状态与日志
  • 创建、关闭或评论 Issue
  • 创建或合并 Pull Request
  • 查询 GitHub API 获取仓库数据
  • 列出仓库、发布版本或协作者

设置

一次性认证:

gh auth login

验证:

gh auth status

常用命令

Pull Requests

# 列出 PR
gh pr list --repo owner/repo

# 检查 CI 状态
gh pr checks 55 --repo owner/repo

# 查看 PR 详情
gh pr view 55 --repo owner/repo

# 创建 PR
gh pr create --title "feat: add feature" --body "Description"

# 合并 PR
gh pr merge 55 --squash --repo owner/repo

Issues

# 列出 Issue
gh issue list --repo owner/repo --state open

# 创建 Issue
gh issue create --title "Bug: something broken" --body "Details..."

# 关闭 Issue
gh issue close 42 --repo owner/repo

CI/工作流运行

# 列出最近的运行
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 run rerun <run-id> --failed --repo owner/repo

API 查询

# 获取指定字段的 PR
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'

# 列出所有标签
gh api repos/owner/repo/labels --jq '.[].name'

# 获取仓库统计
gh api repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'

JSON 输出

多数命令支持 --json 结构化输出,并可配合 --jq 过滤:

gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
gh pr list --json number,title,state,mergeable --jq '.[] | select(.mergeable == "MERGEABLE")'

注意事项

  • 不在 git 目录中时,始终指定 --repo owner/repo
  • 可直接使用 URL:gh pr view https://github.com/owner/repo/pull/55
  • 存在速率限制;重复查询可使用 gh api --cache 1h

适用场景与限制

适用于需要在命令行或自动化流程中查看和管理 GitHub 仓库协作状态的开发者,例如检查 PR 合并就绪情况、排查 CI 失败原因、批量查询仓库信息。使用前提是已安装并认证 gh CLI。关于价格、平台支持范围等更多信息,原文未提供。