github-ops

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub Operations

GitHub操作

Overview

概述

This skill provides comprehensive guidance for GitHub operations using the
gh
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相关任务时,包括拉取请求(PR)管理、议题追踪、仓库操作、工作流自动化和API交互,都可以使用本技能。

When 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
当你需要完成以下任务时,可使用本技能:
  • 创建、查看、编辑或合并拉取请求(PR)
  • 管理GitHub议题或仓库设置
  • 查询GitHub API端点(REST或GraphQL)
  • 处理GitHub Actions工作流
  • 对仓库执行批量操作
  • 与GitHub Enterprise集成
  • 通过CLI或API自动化GitHub操作

Core Operations

核心操作

Pull Requests

拉取请求(PR)

bash
undefined
bash
undefined

Create PR (タイトルはプロジェクトの commit/PR 規約に従う)

Create PR (タイトルはプロジェクトの commit/PR 規約に従う)

gh pr create --title "feat: your PR title" --body "PR description"
gh pr create --title "feat: your PR title" --body "PR description"

List and view PRs

List and view PRs

gh pr list --state open gh pr view 123
gh pr list --state open gh pr view 123

Manage PRs

Manage 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:**
- プロジェクトの規約 (Conventional Commits、チケット ID プレフィックス等) に従う
- チケットトラッカー連携の必須プレフィックスがある場合は導入先の規約文書を参照
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:**
- 遵循项目规范(Conventional Commits、工单ID前缀等)
- 若存在工单追踪系统关联的必填前缀,请参考目标项目的规范文档

Issues

议题

bash
undefined
bash
undefined

Create and manage issues

Create 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 management
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 management

Repositories

仓库

bash
undefined
bash
undefined

View and manage repos

View and manage repos

gh repo view --web gh repo clone owner/repo gh repo create my-new-repo --public
undefined
gh repo view --web gh repo clone owner/repo gh repo create my-new-repo --public
undefined

Workflows

工作流

bash
undefined
bash
undefined

Manage GitHub Actions

Manage 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 operations
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 operations

GitHub API

GitHub API

The
gh api
command provides direct access to GitHub REST API endpoints. Refer to
references/api_reference.md
for comprehensive API endpoint documentation.
Basic API operations:
bash
undefined
The
gh api
command provides direct access to GitHub REST API endpoints. Refer to
references/api_reference.md
for comprehensive API endpoint documentation.
Basic API operations:
bash
undefined

Get PR details via API

Get PR details via API

gh api repos/{owner}/{repo}/pulls/{pr_number}
gh api repos/{owner}/{repo}/pulls/{pr_number}

Add PR comment

Add PR comment

gh api repos/{owner}/{repo}/issues/{pr_number}/comments
-f body="Comment text"
gh api repos/{owner}/{repo}/issues/{pr_number}/comments
-f body="Comment text"

List workflow runs

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

For complex queries requiring multiple related resources, use GraphQL. See `references/api_reference.md` for GraphQL examples.

Authentication and Configuration

认证与配置

bash
undefined
bash
undefined

Login to GitHub

Login to GitHub

gh auth login
gh auth login

Login to GitHub Enterprise

Login to GitHub Enterprise

gh auth login --hostname github.enterprise.com
gh auth login --hostname github.enterprise.com

Check authentication status

Check authentication status

gh auth status
gh auth status

Set default repository

Set default repository

gh repo set-default owner/repo
gh repo set-default owner/repo

Configure gh settings

Configure gh settings

gh config set editor vim gh config set git_protocol ssh gh config list
undefined
gh config set editor vim gh config set git_protocol ssh gh config list
undefined

Output Formats

输出格式

Control output format for programmatic processing:
bash
undefined
控制输出格式以支持程序化处理:
bash
undefined

JSON output

JSON output

gh pr list --json number,title,state,author
gh pr list --json number,title,state,author

JSON with jq processing

JSON with jq processing

gh pr list --json number,title | jq '.[] | select(.title | contains("bug"))'
gh pr list --json number,title | jq '.[] | select(.title | contains("bug"))'

Template output

Template output

gh pr list --template '{{range .}}{{.number}}: {{.title}}{{"\n"}}{{end}}'

📚 See `references/best_practices.md` for shell patterns and automation strategies
gh pr list --template '{{range .}}{{.number}}: {{.title}}{{"\n"}}{{end}}'

📚 See `references/best_practices.md` for shell patterns and automation strategies

Quick Reference

快速参考

Most Common Operations:
bash
gh pr create --title "feat: 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
Most Common Operations:
bash
gh pr create --title "feat: 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

Resources

资源

references/pr_operations.md

references/pr_operations.md

Comprehensive pull request operations including:
  • Detailed PR creation patterns (ticket-tracker 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创建模式(工单追踪系统集成、从文件读取描述、目标分支设置)
  • 查看与筛选策略
  • 评审工作流与审批模式
  • 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 Enterprise使用模式
  • 性能优化
当构建自动化脚本或处理企业部署时,请查阅此参考文档。

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操作或需要详细的端点规范时,请查阅此参考文档。