Skip to content

ismoilovdevml/webhook-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Bridge

Universal Git webhook receiver → Multi-channel notifications

Supported Platforms: GitLab, GitHub, Bitbucket Notification Channels: Telegram, Slack, Discord, Mattermost, Email

✨ Features

  • 🔗 Universal webhook receiver for all major Git platforms
  • 📢 Multi-channel notifications (Telegram, Slack, Discord, Mattermost, Email)
  • 🎨 Customizable message templates (Jinja2)
  • 🔒 End-to-end encryption for sensitive data
  • 🧪 Built-in webhook testing tool
  • 📊 Event history and analytics
  • 🎯 Advanced event filtering
  • 🔄 Automatic retry with exponential backoff
  • ⚡ Rate limiting with proxy support
  • 🐳 Docker-ready with auto-initialization

🚀 Quick Start (3 commands!)

# 1. Clone and enter directory
git clone https://github.com/yourusername/webhook-bridge.git
cd webhook-bridge

# 2. Run setup script (auto-generates secure keys)
bash scripts/setup.sh

# 3. Start services (auto-creates database)
docker-compose up -d

# ✅ Done! Access: http://localhost:3000
# Login credentials shown in setup output

That's it! The database will be automatically created and initialized on first run.

📋 Requirements

  • Docker & Docker Compose
  • Python 3.7+ (for setup script)

🔧 What Happens Automatically

When you run docker-compose up -d:

  1. ✅ Backend container starts
  2. ✅ Database automatically created (if doesn't exist)
  3. ✅ Database schema initialized
  4. ✅ Admin user created
  5. ✅ Services ready to use

No manual migration needed!

Setup

1. Login

2. Add Provider

Dashboard → Channels → Click provider icon → Enter credentials → Test → Save

Telegram: Bot token + Chat ID Slack/Discord/Mattermost: Webhook URL Email: SMTP settings

3. Configure Git Webhook

GitLab:

Settings → Webhooks → Add webhook
URL: https://your-domain.com/api/webhook/git
Triggers: Push, Merge Request, Pipeline, etc.

GitHub:

Settings → Webhooks → Add webhook
Payload URL: https://your-domain.com/api/webhook/git
Content type: application/json
Events: Push, Pull requests, Issues, etc.

Bitbucket:

Repository Settings → Webhooks → Add webhook
URL: https://your-domain.com/api/webhook/git
Triggers: Push, Pull request, etc.

4. Test

Push a commit → Check History tab for events

Production Deployment

Manual Deployment

# 1. Server setup (Ubuntu)
curl -fsSL https://get.docker.com | sh

# 2. Clone and setup
git clone <repo> /opt/webhook-bridge
cd /opt/webhook-bridge
bash scripts/setup.sh production

# 3. Start services
docker-compose up -d

# 4. Check logs
docker-compose logs -f

Nginx Reverse Proxy

server {
    listen 80;
    server_name your-domain.com;

    # Frontend
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # Backend API
    location /api/ {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Secure with SSL:

certbot --nginx -d your-domain.com

Development

# Backend
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload

# Frontend
cd frontend
npm install
npm run dev

🔧 Useful Commands

# View logs
docker-compose logs -f backend

# Restart services
docker-compose restart

# Rebuild after code changes
docker-compose build && docker-compose up -d

# Run backend lint
docker-compose exec backend flake8 app/

# Run frontend lint
docker-compose exec frontend npm run lint

# Access backend shell
docker-compose exec backend bash

# View admin password
cat .env | grep ADMIN_PASSWORD

# Test webhook (sample payloads)
curl http://localhost:8000/api/webhook-test/samples

🧪 Webhook Testing

Built-in testing tool at /api/webhook-test/*:

# Get sample payloads
curl http://localhost:8000/api/webhook-test/samples

# Test webhook parsing
curl -X POST http://localhost:8000/api/webhook-test/parse \
  -H "Content-Type: application/json" \
  -d '{"platform": "gitlab", "event_type": "push"}'

# Test with real provider (replace {id} with provider ID)
curl -X POST http://localhost:8000/api/webhook-test/send \
  -H "Content-Type: application/json" \
  -d '{"platform": "gitlab", "event_type": "push", "provider_id": 1}'

📝 Environment Variables

Auto-generated by setup script:

  • SECRET_KEY - JWT token signing (32+ chars)
  • ENCRYPTION_KEY - Provider data encryption (Fernet key)
  • WEBHOOK_SECRET - Git webhook signature validation
  • ADMIN_PASSWORD - Admin login (16 chars)

Optional configuration:

  • ADMIN_USERNAME - Default: admin
  • ADMIN_EMAIL - Default: admin@localhost
  • ENVIRONMENT - production/development
  • RATE_LIMIT_ENABLED - Default: true
  • RATE_LIMIT_PER_MINUTE - Default: 100

Frontend:

  • VITE_API_URL - API base path (default: /api)
  • VITE_BACKEND_URL - Backend URL for dev (default: http://localhost:8000)

See .env.example for all available options.

Architecture

┌─────────────┐      ┌──────────────┐      ┌─────────────────┐
│   Git       │─────▶│  Webhook     │─────▶│  Notification   │
│   Platform  │      │  Bridge API  │      │  Providers      │
│             │      │              │      │                 │
│ GitLab      │      │ • Parse      │      │ • Telegram      │
│ GitHub      │      │ • Filter     │      │ • Slack         │
│ Bitbucket   │      │ • Transform  │      │ • Discord       │
│             │      │ • Route      │      │ • Mattermost    │
└─────────────┘      └──────────────┘      │ • Email         │
                              │             └─────────────────┘
                              │
                      ┌───────▼────────┐
                      │   Dashboard    │
                      │   (Vue 3)      │
                      │                │
                      │ • History      │
                      │ • Configure    │
                      │ • Monitor      │
                      └────────────────┘

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published