Loading...
Loading...
Automate GitHub operations. Use this skill when you need to manage repositories, create PRs, handle Issues, automate CI/CD, or conduct code reviews.
npx skill4agent add aaaaqwq/claude-code-skills github-automation// 创建仓库
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"
});// 创建新分支
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- 更新了文档"
});// 创建 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"]
});// 获取 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: 添加新功能"
});// 搜索代码
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"
});name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: npm testname: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy
run: ./deploy.sh