Webhook Handler
Purpose
The webhook handler is a Lambda function that receives GitHub webhook events via API Gateway. It validates incoming webhooks, determines if they're relevant to documentation (changes to /docs folders), and triggers the rebuilder Lambda when necessary.
How It Works
The webhook handler processes GitHub events in three stages:
- Validation - Verifies webhook signatures using HMAC SHA-256 to ensure requests are authentic from GitHub
- Event Filtering - Inspects push events to determine if
/docsfolders were modified on the default branch - Trigger - Invokes the docs-rebuilder Lambda asynchronously when relevant changes are detected
Event Types Handled
ping- GitHub's test event when configuring webhooksinstallation.created- When the GitHub App is installed in a new organization (triggers full rebuild)push- Code pushes; only triggers rebuild if/docsfiles changed on the default branch
Structure
Single-file Lambda (index.ts) with focused responsibilities:
handler()- Main Lambda entry point, processes API Gateway eventsverifySignature()- HMAC validation using webhook secret from AWS Secrets ManagertriggerRebuilder()- Invokes the docs-rebuilder Lambda asynchronouslygetWebhookSecret()- Retrieves and caches GitHub webhook secret
Monitoring
Logs are available in DataDog: https://app.datadoghq.eu/logs?query=service%3Adocs-builder
The function is instrumented with DataDog APM for structured logging and tracing.