Overview
The GitHub Webhook Server processes six core GitHub webhook events to automate repository management and pull request workflows. Each event triggers specialized handlers that perform specific automation tasks.Supported GitHub Events
pull_request
Triggers: PR opened, reopened, edited, synchronized, ready_for_review Handler:PullRequestHandler (webhook_server/libs/handlers/pull_request_handler.py)
Automation Actions:
PR Opened / Reopened
PR Opened / Reopened
- Post welcome comment with available commands
- Create tracking issue (if configured)
- Assign reviewers based on OWNERS files
- Apply labels (size, branch, WIP)
- Queue CI/CD checks (tox, pre-commit, container builds)
- Run conventional title validation
- Trigger test oracle (if configured)
PR Synchronized (new commits)
PR Synchronized (new commits)
- Update PR size labels
- Re-run CI/CD checks
- Update merge status labels
- Check for conflicts
- Trigger test oracle on approval (if configured)
PR Edited (title/description changed)
PR Edited (title/description changed)
- Update WIP label based on title
- Re-run conventional title check (if title changed)
PR Ready for Review (draft → ready)
PR Ready for Review (draft → ready)
- Post welcome comment
- Process as new PR (assign reviewers, labels, checks)
issue_comment
Triggers: Comment created on pull request Handler:IssueCommentHandler (webhook_server/libs/handlers/issue_comment_handler.py)
User Commands:
| Command | Action | Permission Required |
|---|---|---|
/verified | Mark PR as verified | OWNERS |
/verified cancel | Remove verification | OWNERS |
/hold | Block PR merging | Anyone |
/hold cancel | Unblock PR merging | Anyone |
/wip | Mark as work in progress | Anyone |
/lgtm | Approve changes (reviewers) | OWNERS reviewers |
/approve | Approve PR (approvers) | OWNERS approvers |
/assign-reviewers | Re-assign reviewers from OWNERS | Anyone |
/check-can-merge | Check merge readiness | Anyone |
/reprocess | Re-run entire PR workflow | OWNERS |
/retest <test-name> | Run specific test | OWNERS |
/retest all | Run all configured tests | OWNERS |
/cherry-pick <branch> | Cherry-pick to branch | OWNERS |
/build-and-push-container | Build and push container | OWNERS |
/test-oracle | AI test recommendations | Anyone |
/automerge | Enable auto-merge | Maintainers |
pull_request_review
Triggers: Review submitted, dismissed Handler:PullRequestReviewHandler (webhook_server/libs/handlers/pull_request_review_handler.py)
Automation Actions:
-
Review Submitted:
- Add review labels (
approved-reviewer,lgtm-reviewer,changes-requested-reviewer,commented-reviewer) - Update approval count
- Check merge readiness
- Trigger test oracle (if configured and approved)
- Add review labels (
-
Review Dismissed:
- Remove corresponding review labels
- Update approval count
- Re-check merge status
APPROVED
Adds
approved-<username> label, counts toward minimum-lgtm requirementCHANGES_REQUESTED
Adds
changes-requested-<username> label, blocks mergeCOMMENTED
Adds
commented-<username> label, informational onlyLGTM Comment
Comment with
/lgtm adds lgtm-<username> labelcheck_run
Triggers: GitHub Actions workflow completion, external CI check completion Handler:CheckRunHandler (webhook_server/libs/handlers/check_run_handler.py)
Automation Actions:
- Check Completed:
- Update merge eligibility based on required checks
- Trigger auto-merge if all checks pass and
automergelabel present - Update
can-be-mergedcheck status - Re-evaluate branch protection rules
push
Triggers: Branch push, tag creation Handler:PushHandler (webhook_server/libs/handlers/push_handler.py)
Automation Actions:
-
Tag Push:
- Build and publish container (if configured)
- Publish to PyPI (if configured)
- Create GitHub release
-
Branch Push:
- Update branch labels on related PRs
- Trigger branch-specific CI/CD
Other Events
While the server can receive any GitHub webhook event, only the six events above trigger active processing. Other events are logged but not processed.
Event Processing Flow
High-Level Flow Diagram
Detailed Processing Steps
Webhook Reception
FastAPI receives webhook at
/webhook_server endpoint with event data in JSON body and headers (X-GitHub-Event, X-GitHub-Delivery, X-Hub-Signature-256)Security Validation
- Verify client IP against GitHub/Cloudflare allowlist (if configured)
- Validate HMAC-SHA256 signature using webhook secret
- Check required headers and fields
Context Creation
Create structured logging context with webhook metadata (hook_id, event_type, repository, action, sender)
GithubWebhook Initialization
- Load repository configuration (global +
.github-webhook-server.yaml) - Select GitHub token with highest rate limit
- Initialize repository API clients
- Track initial rate limit for metrics
Repository Data Pre-Fetch
Fetch comprehensive repository data once (collaborators, protected branches, labels) to minimize API calls
Repository Cloning
Clone repository to temporary directory (optimized with early exits for check_run events)
Handler Routing
Route event to specialized handler based on
X-GitHub-Event header:push→ PushHandlerpull_request→ PullRequestHandlerissue_comment→ IssueCommentHandlerpull_request_review→ PullRequestReviewHandlercheck_run→ CheckRunHandler
Event Processing
Handler performs event-specific automation (assign reviewers, apply labels, run checks, post comments)
Metrics & Logging
- Calculate token spend (rate limit consumption)
- Write structured JSON log to
webhooks_YYYY-MM-DD.json - Update context with final metrics
Event-Specific Processing Examples
Example 1: Pull Request Opened
Example 2: Issue Comment with /lgtm
Example 3: Check Run Completed
Event Filtering & Optimization
Draft PR Handling
Check Run Optimization
Performance Impact: Early exit conditions reduce repository cloning by 90-95%, saving 5-30 seconds per webhook.
Event Configuration
Configure which events trigger specific automation inconfig.yaml:
Related Documentation
Architecture
Event-driven handler architecture overview
User Commands
Complete list of issue comment commands
Configuration
Event-specific configuration options
API Reference
Webhook endpoint specifications