SuperAPI AI Directory

github-automation

Deployment & operations

View repository

Updated 10-15 10:23

About this skill

GitHub Automation Operations

Feature Description

This skill is specifically used 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"

⚠️ Important: Use GitHub MCP to push code

When you need to push to GitHub, prefer using mcporter call github.push_files instead of git push!

Why use GitHub MCP?

  1. ✅ No Personal Access Token required - Uses an authenticated GitHub Copilot token
  2. ✅ Avoids authentication issues - Still works when the SSH key is not configured or the HTTPS token has expired
  3. ✅ Batch commits - Commit multiple files at once
  4. ✅ More reliable - Directly through the GitHub API, unaffected by local git configuration

Code push example

Method 1: Use mcporter (recommended)

# 单个文件
mcporter call github.push_files \
  owner=aAAaqwq \
  repo=my-repo \
  branch=master \
  message="feat: add new feature" \
  files='[{"path":"README.md","content":"file content"}]'

# 多个文件(使用 Python)
python3 << 'EOF'
import json
import subprocess

payload = {
    "owner": "aAAaqwq",
    "repo": "my-repo",
    "branch": "master",
    "message": "feat: update multiple files",
    "files": [
        {"path": "README.md", "content": "..."},
        {"path": "src/main.py", "content": "..."}
    ]
}

result = subprocess.run([
    'mcporter', 'call', 'github.push_files',
    f'owner={payload["owner"]}',
    f'repo={payload["repo"]}',
    f'branch={payload["branch"]}',
    f'message={payload["message"]}',
    f'files={json.dumps(payload["files"])}'
], capture_output=True, text=True)

print(result.stdout)
EOF

Method 2: Traditional git push (requires authentication configuration)

# 仅在 MCP 不可用时使用
git push origin master

MCP Tool List

View all available tools:

mcporter list github --schema

Common tools:

  • github.push_files - Push multiple files to a repository
  • github.create_or_update_file - Create or update a single file
  • github.get_file_contents - Get file contents
  • github.list_commits - List commit history

Core Feature Modules

1. Repository Management

  • Create repository: Create a new public or private repository
  • Fork repository: Fork another repository 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 the file changes of a PR
  • Status check: 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: Batch process multiple Issues

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 the repository
  • Search Issues: Search issues and PRs
  • Search users: Find GitHub users
  • Advanced queries: Use GitHub search syntax

Workflow

Standard development workflow

  1. Create branch: Create a feature branch from main
  2. Develop code: Write and test code
  3. Commit changes: Commit files to the branch
  4. Create PR: Create a Pull Request
  5. Code review: Team reviews the code
  6. Merge code: Merge into the main branch

Automated release workflow

  1. Listen for events: Listen for push or tag events
  2. Run tests: Execute automated tests
  3. Build project: Compile and package
  4. Create Release: Publish a new version
  5. Deploy application: Automatically deploy to production

Issue management workflow

  1. Create Issue: Report a problem or requirement
  2. Assign tasks: Specify the person responsible
  3. Add labels: Classification and priority
  4. Track progress: Update status
  5. 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 a moderate size

Branch strategy

  • Use Git Flow or GitHub Flow
  • Protect the main branch
  • Regularly sync with 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 branches and Pull Requests

// 创建新分支
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 appropriate personnel

3. Release Management

  • Listen for version tags
  • Generate changelog
  • Create GitHub Release
  • Notify team members

4. Dependency Updates

  • Regularly check for dependency updates
  • Create update PR
  • Run tests for verification
  • Automatically merge security updates

Notes

  • Comply with GitHub API rate limits
  • Authenticate using Personal Access Token
  • Properly handle API errors and retries
  • Protect sensitive information and keys
  • Follow open source project contribution guidelines