GitHub 集成
让你的代理通过 GitHub 管理仓库、issue 和发布。借助 AI 驱动的自动化,创建和更新 issue、管理版本发布、跟踪项目开发,并简化软件开发工作流。
在使用 GitHub 集成前,请确保你已经具备:
- 一个拥有有效订阅的 CrewAI AMP 账号
- 一个具有相应仓库权限的 GitHub 账号
- 已通过 集成页面 连接你的 GitHub 账号
配置 GitHub 集成
Section titled “配置 GitHub 集成”1. 连接你的 GitHub 账号
Section titled “1. 连接你的 GitHub 账号”- 进入 CrewAI AMP Integrations
- 在身份验证集成部分找到 GitHub
- 点击 Connect 并完成 OAuth 流程
- 授予仓库和 issue 管理所需的权限
- 从 Integration Settings 复制你的 Enterprise Token
2. 安装所需包
Section titled “2. 安装所需包”uv add crewai-tools3. 环境变量设置
Section titled “3. 环境变量设置”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"或者将其添加到你的 .env 文件中:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokengithub/create_issue
描述: 在 GitHub 中创建 issue。
参数:
owner(string, required): 所有者 - 指定与该 Issue 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Issue 相关的仓库名称。title(string, required): Issue 标题 - 指定要创建的 issue 标题。body(string, optional): Issue 内容 - 指定要创建的 issue 内容。assignees(string, optional): 负责人 - 以字符串数组形式指定该 issue 的 GitHub 登录名。(示例:["octocat"])。
github/update_issue
描述: 在 GitHub 中更新 issue。
参数:
owner(string, required): 所有者 - 指定与该 Issue 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Issue 相关的仓库名称。issue_number(string, required): Issue 编号 - 指定要更新的 issue 编号。title(string, required): Issue 标题 - 指定要更新的 issue 标题。body(string, optional): Issue 内容 - 指定要更新的 issue 内容。assignees(string, optional): 负责人 - 以字符串数组形式指定该 issue 的 GitHub 登录名。(示例:["octocat"])。state(string, optional): 状态 - 指定该 issue 的更新后状态。- 可选项:
open,closed
- 可选项:
github/get_issue_by_number
描述: 在 GitHub 中通过编号获取 issue。
参数:
owner(string, required): 所有者 - 指定与该 Issue 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Issue 相关的仓库名称。issue_number(string, required): Issue 编号 - 指定要获取的 issue 编号。
github/lock_issue
描述: 在 GitHub 中锁定 issue。
参数:
owner(string, required): 所有者 - 指定与该 Issue 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Issue 相关的仓库名称。issue_number(string, required): Issue 编号 - 指定要锁定的 issue 编号。lock_reason(string, required): 锁定原因 - 指定锁定该 issue 或 pull request 对话的原因。- 可选项:
off-topic,too heated,resolved,spam
- 可选项:
github/search_issue
描述: 在 GitHub 中搜索 issue。
参数:
owner(string, required): 所有者 - 指定与该 Issue 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Issue 相关的仓库名称。filter(object, required): 以析取范式表示的筛选器 - 若干 AND 条件组的 OR。可用字段:{"operator": "OR","conditions": [{"operator": "AND","conditions": [{"field": "assignee","operator": "$stringExactlyMatches","value": "octocat"}]}]}assignee,creator,mentioned,labels
github/create_release
描述: 在 GitHub 中创建发布。
参数:
owner(string, required): 所有者 - 指定与该 Release 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Release 相关的仓库名称。tag_name(string, required): 名称 - 指定要创建的 release 标签名称。(示例:"v1.0.0")。target_commitish(string, optional): 目标 - 指定 release 的目标。可以是分支名或 commit SHA。默认为主分支。(示例:"master")。body(string, optional): 正文 - 指定该 release 的描述。draft(string, optional): 草稿 - 指定创建的 release 是否应为草稿(未发布)release。- 可选项:
true,false
- 可选项:
prerelease(string, optional): 预发布 - 指定创建的 release 是否应为预发布版本。- 可选项:
true,false
- 可选项:
discussion_category_name(string, optional): 讨论分类名称 - 如果指定,会创建对应分类的讨论并链接到该 release。该值必须是仓库中已存在的分类。generate_release_notes(string, optional): 发布说明 - 指定创建的 release 是否应使用提供的名称和正文自动生成发布说明。- 可选项:
true,false
- 可选项:
github/update_release
描述: 在 GitHub 中更新 release。
参数:
owner(string, required): 所有者 - 指定与该 Release 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Release 相关的仓库名称。id(string, required): Release ID - 指定要更新的 release ID。tag_name(string, optional): 名称 - 指定要更新的 release 标签名称。(示例:"v1.0.0")。target_commitish(string, optional): 目标 - 指定 release 的目标。可以是分支名或 commit SHA。默认为主分支。(示例:"master")。body(string, optional): 正文 - 指定该 release 的描述。draft(string, optional): 草稿 - 指定创建的 release 是否应为草稿(未发布)release。- 可选项:
true,false
- 可选项:
prerelease(string, optional): 预发布 - 指定创建的 release 是否应为预发布版本。- 可选项:
true,false
- 可选项:
discussion_category_name(string, optional): 讨论分类名称 - 如果指定,会创建对应分类的讨论并链接到该 release。该值必须是仓库中已存在的分类。generate_release_notes(string, optional): 发布说明 - 指定创建的 release 是否应使用提供的名称和正文自动生成发布说明。- 可选项:
true,false
- 可选项:
github/get_release_by_id
描述: 在 GitHub 中通过 ID 获取 release。
参数:
owner(string, required): 所有者 - 指定与该 Release 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Release 相关的仓库名称。id(string, required): Release ID - 指定要获取的 release ID。
github/get_release_by_tag_name
描述: 在 GitHub 中通过标签名获取 release。
参数:
owner(string, required): 所有者 - 指定与该 Release 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Release 相关的仓库名称。tag_name(string, required): 名称 - 指定要获取的 release 标签。(示例:"v1.0.0")。
github/delete_release
描述: 在 GitHub 中删除 release。
参数:
owner(string, required): 所有者 - 指定与该 Release 相关仓库的账户所有者名称。(示例:"abc")。repo(string, required): 仓库 - 指定与该 Release 相关的仓库名称。id(string, required): Release ID - 指定要删除的 release ID。
基础 GitHub 代理设置
Section titled “基础 GitHub 代理设置”from crewai import Agent, Task, Crewfrom crewai import Agent, Task, Crew
# Create an agent with Github capabilitiesgithub_agent = Agent( role="Repository Manager", goal="Manage GitHub repositories, issues, and releases efficiently", backstory="An AI assistant specialized in repository management and issue tracking.", apps=['github'] # All Github actions will be available)
# Task to create a new issuecreate_issue_task = Task( description="Create a bug report issue for the login functionality in the main repository", agent=github_agent, expected_output="Issue created successfully with issue number")
# Run the taskcrew = Crew( agents=[github_agent], tasks=[create_issue_task])
crew.kickoff()筛选特定 GitHub 工具
Section titled “筛选特定 GitHub 工具”issue_manager = Agent( role="Issue Manager", goal="Create and manage GitHub issues efficiently", backstory="An AI assistant that focuses on issue tracking and management.", apps=['github/create_issue'])
# Task to manage issue workflowissue_workflow = Task( description="Create a feature request issue and assign it to the development team", agent=issue_manager, expected_output="Feature request issue created and assigned successfully")
crew = Crew( agents=[issue_manager], tasks=[issue_workflow])
crew.kickoff()from crewai import Agent, Task, Crew
release_manager = Agent( role="Release Manager", goal="Manage software releases and versioning", backstory="An experienced release manager who handles version control and release processes.", apps=['github'])
# Task to create a new releaserelease_task = Task( description=""" Create a new release v2.1.0 for the project with: - Auto-generated release notes - Target the main branch - Include a description of new features and bug fixes """, agent=release_manager, expected_output="Release v2.1.0 created successfully with release notes")
crew = Crew( agents=[release_manager], tasks=[release_task])
crew.kickoff()Issue 跟踪与管理
Section titled “Issue 跟踪与管理”from crewai import Agent, Task, Crew
project_coordinator = Agent( role="Project Coordinator", goal="Track and coordinate project issues and development progress", backstory="An AI assistant that helps coordinate development work and track project progress.", apps=['github'])
# Complex task involving multiple GitHub operationscoordination_task = Task( description=""" 1. Search for all open issues assigned to the current milestone 2. Identify overdue issues and update their priority labels 3. Create a weekly progress report issue 4. Lock resolved issues that have been inactive for 30 days """, agent=project_coordinator, expected_output="Project coordination completed with progress report and issue management")
crew = Crew( agents=[project_coordinator], tasks=[coordination_task])
crew.kickoff()需要帮助?
如需 GitHub 集成设置或故障排查方面的帮助,请联系我们的支持团队。