Skip to content

rolniuq/robolo

Repository files navigation

GitHub Bot

A comprehensive GitHub bot written in Go that automates common repository management tasks.

Features

  • 🏷️ Auto-labeling: Automatically labels issues and PRs based on content
  • 👋 Welcome messages: Greets new contributors
  • 📝 Comment automation: Smart comments on issues and PRs
  • 🗂️ File analysis: Analyzes changed files in pull requests
  • Stale issue management: Identifies and closes stale issues
  • 🚀 RESTful API: HTTP endpoints for manual bot control

Quick Start

  1. Clone and setup:

    git clone <repository-url>
    cd github-bot
    go mod tidy
  2. Set environment variables:

    export GITHUB_TOKEN="your_github_token"
    export GITHUB_WEBHOOK_SECRET="your_webhook_secret"
    export PORT="8080"
  3. Run the bot:

    go run simple-bot.go

Bot Actions

Auto-labeling

The bot automatically adds labels based on content:

  • bug - Contains bug/error keywords
  • enhancement - Feature requests
  • documentation - Doc related issues
  • question - Help/questions
  • urgent - High priority issues
  • size/small|medium|large - Based on description length

Welcome Messages

New contributors get a friendly welcome message with:

  • Repository guidelines
  • Contribution tips
  • Getting started resources

Pull Request Analysis

  • Suggests reviewers based on file types
  • Identifies first-time contributors
  • Analyzes code changes

Stale Management

  • Marks issues as stale after 30 days
  • Sends warning comments
  • Closes if no activity continues

API Endpoints

  • POST /webhook - GitHub webhook receiver
  • GET /health - Health check
  • POST /test-issue - Create test issue

Webhook Events

Bot handles these GitHub events:

  • issues - New, updated, labeled issues
  • pull_request - PR openings, updates, merges
  • push - Code pushes
  • repository - Repo creation, archiving

Configuration

Variable Description Required
GITHUB_TOKEN GitHub personal access token
GITHUB_WEBHOOK_SECRET Webhook verification secret
PORT Server port ❌ (default: 8080)
LOG_LEVEL Logging level ❌ (default: info)

Deployment

Docker

docker build -t github-bot .
docker run -e GITHUB_TOKEN=$GITHUB_TOKEN -p 8080:8080 github-bot

Railway

railway up

Vercel

vercel --prod

Development

Project Structure

github-bot/
├── cmd/                 # Application entrypoint
├── internal/
│   ├── handlers/        # HTTP request handlers
│   ├── services/        # Business logic
│   └── config/          # Configuration
├── pkg/
│   ├── github/          # GitHub API wrapper
│   └── logger/         # Logging utilities
└── webhooks/           # Webhook event processing

Adding New Features

  1. Add webhook handler:

    handler.RegisterEventHandler("new_event", func(w http.ResponseWriter, r *http.Request, payload interface{}) {
        // Handle event
    })
  2. Add bot service:

    func (s *BotService) NewFeature(ctx context.Context, event *github.Event) error {
        // Implement feature
    }
  3. Create API endpoint:

    api.HandleFunc("/new-feature", handleNewFeature(service)).Methods("POST")

Security

  • 🔒 Webhook signature verification
  • 🔑 Token-based authentication
  • 🛡️ Input validation and sanitization
  • 📝 Comprehensive logging

Monitoring

The bot provides:

  • Structured JSON logging
  • Health check endpoints
  • Error tracking
  • Performance metrics

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published