This repository contains a GitHub bot powered by JamAIBase, written in Go. This bot is designed to automate various GitHub repository tasks, including issue management, pull request handling, and more. This documentation provides a detailed guide on how to set up, configure, and use the bot, including an explanation of its main features and components.
Clone the Repository: You should clone this repository into your existing repository as a submodule, or simply copy it over.
git clone https://github.com/wenjielee1/github-bot.git
mv github-bot path/to/your/repo
or if you are adding it as a submodule, from the root folder,
git submodule add https://github.com/wenjielee1/github-bot path/to/submodule/github-bot
git submodule update --init --recursive
Install Dependencies:
go mod tidy
Build the Project:
go build
The bot requires several environment variables to function correctly. These can be set in a .env
file or directly in your environment.
TRIAGE_BOT_PRIVATE_KEY
: The private key for your GitHub App.TRIAGE_BOT_APP_ID
: Your GitHub App ID.TRIAGE_BOT_JAMAI_KEY
: The API key for JamAIBase.TRIAGE_BOT_JAMAI_PROJECT_ID
: The project ID for JamAIBase. You should create a project in our dashboardInstall the JambuBot App:
Retrieve App ID and Installation ID:
Generate a Private Key:
.pem
file. Keep this file secure.Set Up Environment Variables:
Setup workflow
github-bot/.github
folder, or if you already have existing workflows, .github/workflows/github_bot.yml
into your project root.github_bot.yml
to correctly navigate through your repository structure. You may do this under job Build and run Go Script
The bot includes several key features, each powered by JamAIBase:
issues
, pull_request
, and push
. JamAIBase processes the events, ensuring that the bot's responses are timely and accurate.Run the Bot:
Set Up Env Configs:
To test the bot, you need to set the environment variables directly inside the test scripts under github-bot/test
and generate a .pem
file for the private key.
Set Environment Variables:
GITHUB_APP_ID
, GITHUB_INSTALLATION_ID
, GITHUB_APP_PRIVATE_KEY
, and other required environment variables.Generate Private Key:
.pem
file after installing the JambuBot app to get the private key. Use this file in your test scripts.Run Test Scripts:
go run create.go
go run delete.go
To contribute to the development of this bot, follow these steps:
Fork the Repository:
Create a New Branch:
git checkout -b feature-branch
Make Your Changes:
Submit a Pull Request:
We welcome contributions to improve the bot. Please ensure that your contributions adhere to the project's coding standards and conventions. Before submitting a pull request, make sure to:
main.go
The main entry point of the application. It initializes the server and sets up the routes for handling GitHub webhook events.
eventHandler.go
Contains the event handling logic for different GitHub webhook events. It routes the events to the appropriate handlers based on the event type.
issueHandler.go
Defines functions for handling issue-related events, such as creating, commenting on, and closing issues.
prHandler.go
Contains logic for handling pull request events, including reviewing pull requests and suggesting labels.
githubModels.go
Defines data structures for GitHub-related entities, such as issues and pull requests.
jamaiModels.go
Defines data structures for JamAIBase-related entities.
authService.go
Provides authentication services, including retrieving installation tokens for the GitHub App and JamAIBase headers.
issueService.go
Implements the business logic for issue handling, such as creating and commenting on issues.
jamaiService.go
Handles interactions with JamAIBase, such as sending requests and processing responses.
prService.go
Implements the business logic for pull request handling, such as reviewing commits for potential issues and suggesting labels.
This documentation provides a comprehensive guide to understanding, setting up, and contributing to the github-bot
. For detailed implementation, refer to the source code in the respective files.