A lightweight, secure webhook receiver service built in Rust that integrates with GitHub repositories to automate workflows and respond to repository events.
- Secure webhook signature verification
- Support for multiple GitHub event types (push, pull_request, issues, ping)
- JSON logging and structured responses
- Health check endpoint
- CORS support for web integrations
- Configurable via CLI arguments or environment variables
- Production-ready with proper error handling
git clone <your-repo>
cd github-webhook-service
cargo build --release
# Run with webhook secret
cargo run -- --port 6666 --secret your-webhook-secret- Go to your GitHub repository
- Navigate to Settings → Webhooks
- Click "Add webhook"
- Configure:
- Payload URL:
https://your-domain.com/webhook - Content type:
application/json - Secret: Use the same secret as your service
- Events: Select events you want to handle
- Payload URL:
# Health check
curl http://localhost:6666/health
# Service info
curl http://localhost:6666/
# GitHub will automatically send a ping event to test the webhookgithub-webhook-service --help
Options:
-p, --port <PORT> Port to run the server on [default: 6666]
-s, --secret <SECRET> GitHub webhook secret [env: GITHUB_WEBHOOK_SECRET]
-h, --help Print help
-V, --version Print versionGITHUB_WEBHOOK_SECRET: Your GitHub webhook secret
The service currently handles these GitHub events:
- push: Repository push events
- pull_request: PR opened, closed, synchronized, etc.
- issues: Issue opened, closed, edited, etc.
- ping: GitHub webhook test event
// In handle_webhook function, add new event types:
match event_type {
"release" => {
info!("Processing release event");
}
"workflow_run" => {
info!("Processing workflow run event");
}
}The service includes a reqwest::Client in the app state for making HTTP requests:
async fn handle_custom_event(state: &AppState, payload: &WebhookPayload) -> Result<(), StatusCode> {
let response = state.http_client
.post("https://api.example.com/notify")
.json(&payload)
.send()
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
Ok(())
}Receives GitHub webhook events. Requires proper signature if secret is configured.
Health check endpoint. Returns service status and version.
Service information endpoint. Lists supported events and endpoints.
- Automated Testing: Trigger test suites on PR events
- Deployment Pipeline: Deploy on push to main branch
- Issue Management: Auto-assign labels or notify teams
- Code Quality: Run linters and security scans
- Notifications: Send Slack/Discord messages on events
- Webhook delivery failed: Check URL accessibility and HTTPS certificate
- Signature verification failed: Ensure secret matches between GitHub and service
- Events not processing: Check GitHub event selection in webhook settings
- Service unreachable: Verify firewall settings and port configuration
Run with debug logging:
RUST_LOG=debug cargo run -- --port 6666 --secret your-secret- Fork the repository
- Create a feature branch
- Submit a pull request
This project is open source and available under the MIT License.