github-ops
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Operations
GitHub 操作
Overview
概述
This skill provides comprehensive guidance for GitHub operations using the CLI tool and GitHub REST/GraphQL APIs. Use this skill when performing any GitHub-related tasks including pull request management, issue tracking, repository operations, workflow automation, and API interactions.
gh本技能提供使用 CLI工具和GitHub REST/GraphQL API进行GitHub操作的全面指南。在执行任何GitHub相关任务时使用本技能,包括拉取请求管理、议题追踪、仓库操作、工作流自动化和API交互。
ghWhen to Use This Skill
适用场景
This skill activates for tasks involving:
- Creating, viewing, editing, or merging pull requests
- Managing GitHub issues or repository settings
- Querying GitHub API endpoints (REST or GraphQL)
- Working with GitHub Actions workflows
- Performing bulk operations on repositories
- Integrating with GitHub Enterprise
- Automating GitHub operations via CLI or API
当涉及以下任务时,可激活本技能:
- 创建、查看、编辑或合并拉取请求
- 管理GitHub议题或仓库设置
- 查询GitHub API端点(REST或GraphQL)
- 处理GitHub Actions工作流
- 对仓库执行批量操作
- 与GitHub Enterprise集成
- 通过CLI或API自动化GitHub操作
Core Operations
核心操作
Pull Requests
拉取请求
bash
undefinedbash
undefinedCreate PR with NOJIRA prefix (bypasses JIRA enforcement checks)
创建带NOJIRA前缀的PR(绕过JIRA强制检查)
gh pr create --title "NOJIRA: Your PR title" --body "PR description"
gh pr create --title "NOJIRA: Your PR title" --body "PR description"
List and view PRs
列出并查看PRs
gh pr list --state open
gh pr view 123
gh pr list --state open
gh pr view 123
Manage PRs
管理PRs
gh pr merge 123 --squash
gh pr review 123 --approve
gh pr comment 123 --body "LGTM"
📚 See `references/pr_operations.md` for comprehensive PR workflows
**PR Title Convention:**
- With JIRA ticket: `GR-1234: Descriptive title`
- Without JIRA ticket: `NOJIRA: Descriptive title`gh pr merge 123 --squash
gh pr review 123 --approve
gh pr comment 123 --body "LGTM"
📚 查看`references/pr_operations.md`获取全面的PR工作流
**PR标题规范:**
- 带JIRA工单: `GR-1234: Descriptive title`
- 不带JIRA工单: `NOJIRA: Descriptive title`Issues
议题
bash
undefinedbash
undefinedCreate and manage issues
创建并管理议题
gh issue create --title "Bug: Issue title" --body "Issue description"
gh issue list --state open --label bug
gh issue edit 456 --add-label "priority-high"
gh issue close 456
📚 See `references/issue_operations.md` for detailed issue managementgh issue create --title "Bug: Issue title" --body "Issue description"
gh issue list --state open --label bug
gh issue edit 456 --add-label "priority-high"
gh issue close 456
📚 查看`references/issue_operations.md`获取详细的议题管理指南Repositories
仓库
bash
undefinedbash
undefinedView and manage repos
查看和管理仓库
gh repo view --web
gh repo clone owner/repo
gh repo create my-new-repo --public
undefinedgh repo view --web
gh repo clone owner/repo
gh repo create my-new-repo --public
undefinedWorkflows
工作流
bash
undefinedbash
undefinedManage GitHub Actions
管理GitHub Actions
gh workflow list
gh workflow run workflow-name
gh run watch run-id
gh run download run-id
📚 See `references/workflow_operations.md` for advanced workflow operationsgh workflow list
gh workflow run workflow-name
gh run watch run-id
gh run download run-id
📚 查看`references/workflow_operations.md`获取高级工作流操作指南GitHub API
GitHub API
The command provides direct access to GitHub REST API endpoints. Refer to for comprehensive API endpoint documentation.
gh apireferences/api_reference.mdBasic API operations:
bash
undefinedgh apireferences/api_reference.md基础API操作:
bash
undefinedGet PR details via API
通过API获取PR详情
gh api repos/{owner}/{repo}/pulls/{pr_number}
gh api repos/{owner}/{repo}/pulls/{pr_number}
Add PR comment
添加PR评论
gh api repos/{owner}/{repo}/issues/{pr_number}/comments
-f body="Comment text"
-f body="Comment text"
gh api repos/{owner}/{repo}/issues/{pr_number}/comments
-f body="Comment text"
-f body="Comment text"
List workflow runs
列出工作流运行记录
gh api repos/{owner}/{repo}/actions/runs
For complex queries requiring multiple related resources, use GraphQL. See `references/api_reference.md` for GraphQL examples.gh api repos/{owner}/{repo}/actions/runs
对于需要多个关联资源的复杂查询,请使用GraphQL。查看`references/api_reference.md`获取GraphQL示例。Authentication and Configuration
身份验证与配置
bash
undefinedbash
undefinedLogin to GitHub
登录GitHub
gh auth login
gh auth login
Login to GitHub Enterprise
登录GitHub Enterprise
gh auth login --hostname github.enterprise.com
gh auth login --hostname github.enterprise.com
Check authentication status
检查身份验证状态
gh auth status
gh auth status
Set default repository
设置默认仓库
gh repo set-default owner/repo
gh repo set-default owner/repo
Configure gh settings
配置gh设置
gh config set editor vim
gh config set git_protocol ssh
gh config list
undefinedgh config set editor vim
gh config set git_protocol ssh
gh config list
undefinedOutput Formats
输出格式
Control output format for programmatic processing:
bash
undefined控制输出格式以支持程序化处理:
bash
undefinedJSON output
JSON输出
gh pr list --json number,title,state,author
gh pr list --json number,title,state,author
JSON with jq processing
结合jq处理JSON
gh pr list --json number,title | jq '.[] | select(.title | contains("bug"))'
gh pr list --json number,title | jq '.[] | select(.title | contains("bug"))'
Template output
模板输出
gh pr list --template '{{range .}}{{.number}}: {{.title}}{{"\n"}}{{end}}'
📚 See `references/best_practices.md` for shell patterns and automation strategiesgh pr list --template '{{range .}}{{.number}}: {{.title}}{{"\n"}}{{end}}'
📚 查看`references/best_practices.md`获取Shell模式和自动化策略Quick Reference
快速参考
Most Common Operations:
bash
gh pr create --title "NOJIRA: Title" --body "Description" # Create PR
gh pr list # List PRs
gh pr view 123 # View PR details
gh pr checks 123 # Check PR status
gh pr merge 123 --squash # Merge PR
gh pr comment 123 --body "LGTM" # Comment on PR
gh issue create --title "Title" --body "Description" # Create issue
gh workflow run workflow-name # Run workflow
gh repo view --web # Open repo in browser
gh api repos/{owner}/{repo}/pulls/{pr_number} # Direct API call最常用操作:
bash
gh pr create --title "NOJIRA: Title" --body "Description" # 创建PR
gh pr list # 列出PRs
gh pr view 123 # 查看PR详情
gh pr checks 123 # 检查PR状态
gh pr merge 123 --squash # 合并PR
gh pr comment 123 --body "LGTM" # 评论PR
gh issue create --title "Title" --body "Description" # 创建议题
gh workflow run workflow-name # 运行工作流
gh repo view --web # 在浏览器中打开仓库
gh api repos/{owner}/{repo}/pulls/{pr_number} # 直接调用APIResources
资源
references/pr_operations.md
references/pr_operations.md
Comprehensive pull request operations including:
- Detailed PR creation patterns (JIRA integration, body from file, targeting branches)
- Viewing and filtering strategies
- Review workflows and approval patterns
- PR lifecycle management
- Bulk operations and automation examples
Load this reference when working with complex PR workflows or bulk operations.
全面的拉取请求操作指南,包括:
- 详细的PR创建模式(JIRA集成、从文件读取描述、目标分支设置)
- 查看与筛选策略
- 评审工作流与审批模式
- PR生命周期管理
- 批量操作与自动化示例
在处理复杂PR工作流或批量操作时,请查阅本参考文档。
references/issue_operations.md
references/issue_operations.md
Detailed issue management examples including:
- Issue creation with labels and assignees
- Advanced filtering and search
- Issue lifecycle and state management
- Bulk operations on multiple issues
- Integration with PRs and projects
Load this reference when managing issues at scale or setting up issue workflows.
详细的议题管理示例,包括:
- 带标签和指派人的议题创建
- 高级筛选与搜索
- 议题生命周期与状态管理
- 多议题批量操作
- 与PR和项目的集成
在大规模管理议题或设置议题工作流时,请查阅本参考文档。
references/workflow_operations.md
references/workflow_operations.md
Advanced GitHub Actions workflow operations including:
- Workflow triggers and manual runs
- Run monitoring and debugging
- Artifact management
- Secrets and variables
- Performance optimization strategies
Load this reference when working with CI/CD workflows or debugging failed runs.
高级GitHub Actions工作流操作指南,包括:
- 工作流触发与手动运行
- 运行监控与调试
- 工件管理
- 密钥与变量
- 性能优化策略
在处理CI/CD工作流或调试失败运行时,请查阅本参考文档。
references/best_practices.md
references/best_practices.md
Shell scripting patterns and automation strategies including:
- Output formatting (JSON, templates, jq)
- Pagination and large result sets
- Error handling and retry logic
- Bulk operations and parallel execution
- Enterprise GitHub patterns
- Performance optimization
Load this reference when building automation scripts or handling enterprise deployments.
Shell脚本模式与自动化策略,包括:
- 输出格式(JSON、模板、jq)
- 分页与大型结果集处理
- 错误处理与重试逻辑
- 批量操作与并行执行
- 企业版GitHub模式
- 性能优化
在构建自动化脚本或处理企业部署时,请查阅本参考文档。
references/api_reference.md
references/api_reference.md
Contains comprehensive GitHub REST API endpoint documentation including:
- Complete API endpoint reference with examples
- Request/response formats
- Authentication patterns
- Rate limiting guidance
- Webhook configurations
- Advanced GraphQL query patterns
Load this reference when performing complex API operations or when needing detailed endpoint specifications.
包含全面的GitHub REST API端点文档,包括:
- 完整的API端点参考与示例
- 请求/响应格式
- 身份验证模式
- 速率限制指南
- Webhook配置
- 高级GraphQL查询模式
在执行复杂API操作或需要详细端点规范时,请查阅本参考文档。