Feature Description
This skill is specifically designed to automate various operations on the GitHub platform, including:
- Repository management and file operations
- Pull Request creation and review
- Issue management and tracking
- Branch management and merging
- CI/CD workflow automation
- Code search and analysis
Use Cases
- "Create a new GitHub repository"
- "Commit code and create a Pull Request"
- "Batch process GitHub Issues"
- "Automate the code review process"
- "Search for specific code in a codebase"
- "Manage GitHub Actions workflows"
Core Feature Modules
1. Repository Management
- Create Repository: Create a new public or private repository
- Fork Repository: Fork other repositories to your own account
- Search Repositories: Search repositories by keyword
- File Operations: Read, create, update files
- Batch Commit: Commit multiple files at once
2. Pull Request Management
- Create PR: Create a Pull Request from a branch
- Review PR: Add comments and review feedback
- Merge PR: Merge a Pull Request
- View Changes: Get file changes of a PR
- Status Checks: View CI/CD status
3. Issue Management
- Create Issue: Create a new issue or task
- Update Issue: Modify status, labels, assignees
- Search Issues: Filter Issues by criteria
- Add Comments: Add discussion in an Issue
- Batch Operations: Process multiple Issues in batch
4. Branch Management
- Create Branch: Create a new branch from a specified branch
- View Commits: List the commit history of a branch
- Branch Protection: Configure branch protection rules
- Merge Strategy: Choose the merge method (merge, squash, rebase)
5. Code Search
- Search Code: Search for code snippets in repositories
- Search Issues: Search issues and PRs
- Search Users: Find GitHub users
- Advanced Queries: Use GitHub search syntax
Workflow
Standard Development Flow
- Create Branch: Create a feature branch from main
- Develop Code: Write and test code
- Commit Changes: Commit files to the branch
- Create PR: Create a Pull Request
- Code Review: Team reviews the code
- Merge code: Merge to main branch
Automated release process
- Listen for events: Listen for push or tag events
- Run tests: Execute automated tests
- Build project: Compile and package
- Create Release: Publish a new version
- Deploy application: Automatically deploy to production environment
Issue management process
- Create Issue: Report a problem or requirement
- Assign task: Specify the person responsible
- Add labels: Classification and priority
- Track progress: Update status
- Close Issue: Close after completion
Best practices
Commit conventions
- Use clear commit messages
- Follow the Conventional Commits specification
- One commit solves one problem
- Include necessary tests and documentation
PR conventions
- Provide a detailed PR description
- Link related Issues
- Ensure CI checks pass
- Respond to review comments promptly
- Keep PRs reasonably sized
Branching strategy
- Use Git Flow or GitHub Flow
- Protect the main branch
- Regularly sync the upstream branch
- Delete merged branches promptly
Security practices
- Do not commit sensitive information
- Use GitHub Secrets to manage keys
- Enable two-factor authentication
- Regularly review permission settings
Common code examples
1. Create a repository and commit files
// 创建仓库
const repo = await createRepository({
name: "my-project",
description: "项目描述",
private: false,
autoInit: true
});
// 批量提交文件
await pushFiles({
owner: "username",
repo: "my-project",
branch: "main",
files: [
{
path: "README.md",
content: "# My Project\n\n项目说明"
},
{
path: "src/index.js",
content: "console.log('Hello World');"
}
],
message: "Initial commit"
});
2. Create a branch and Pull Request
// 创建新分支
await createBranch({
owner: "username",
repo: "my-project",
branch: "feature/new-feature",
from_branch: "main"
});
// 提交代码到新分支
await createOrUpdateFile({
owner: "username",
repo: "my-project",
path: "src/feature.js",
content: "// 新功能代码",
message: "Add new feature",
branch: "feature/new-feature"
});
// 创建 Pull Request
await createPullRequest({
owner: "username",
repo: "my-project",
title: "添加新功能",
head: "feature/new-feature",
base: "main",
body: "## 变更说明\n- 添加了新功能\n- 更新了文档"
});
3. Issue management
// 创建 Issue
const issue = await createIssue({
owner: "username",
repo: "my-project",
title: "修复登录问题",
body: "## 问题描述\n用户无法登录\n\n## 复现步骤\n1. 打开登录页面\n2. 输入凭证\n3. 点击登录",
labels: ["bug", "high-priority"],
assignees: ["developer1"]
});
// 添加评论
await addIssueComment({
owner: "username",
repo: "my-project",
issue_number: issue.number,
body: "正在调查此问题"
});
// 更新 Issue
await updateIssue({
owner: "username",
repo: "my-project",
issue_number: issue.number,
state: "closed",
labels: ["bug", "fixed"]
});
4. Code review
// 获取 PR 详情
const pr = await getPullRequest({
owner: "username",
repo: "my-project",
pull_number: 123
});
// 获取 PR 文件变更
const files = await getPullRequestFiles({
owner: "username",
repo: "my-project",
pull_number: 123
});
// 创建审查
await createPullRequestReview({
owner: "username",
repo: "my-project",
pull_number: 123,
body: "代码看起来不错,有几点建议",
event: "COMMENT",
comments: [
{
path: "src/index.js",
line: 10,
body: "建议添加错误处理"
}
]
});
// 合并 PR
await mergePullRequest({
owner: "username",
repo: "my-project",
pull_number: 123,
merge_method: "squash",
commit_title: "feat: 添加新功能"
});
5. Search and query
// 搜索代码
const codeResults = await searchCode({
q: "function login repo:username/my-project"
});
// 搜索 Issue
const issueResults = await searchIssues({
q: "is:open label:bug repo:username/my-project",
sort: "created",
order: "desc"
});
// 搜索仓库
const repoResults = await searchRepositories({
query: "react stars:>1000 language:javascript"
});
GitHub Actions integration
Automated testing
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: npm test
Automated deployment
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy
run: ./deploy.sh
Integration scenarios
1. Automated code review
- Listen for PR creation events
- Run code quality checks
- Automatically add review comments
- Mark areas that need improvement
2. Automatic Issue classification
- Listen for Issue creation
- Analyze Issue content
- Automatically add labels
- Assign to the appropriate person
3. Release management
- Listen for version tags
- Generate a changelog
- Create a GitHub Release
- Notify team members
4. Dependency updates
- Regularly check for dependency updates
- Create update PRs
- Run tests for verification
- Automatically merge security updates
Notes
- Comply with GitHub API rate limits
- Use a Personal Access Token for authentication
- Properly handle API errors and retries
- Protect sensitive information and keys
- Follow open source project contribution guidelines