spatie/laravel-github-webhooks
Handle GitHub webhooks in Laravel: verify signatures, log valid calls, and dispatch jobs/events per webhook type. Includes a GitHubWebhookCall model to access payloads and queueable handlers for event-driven integrations.
ShouldQueue) and event listeners, making it a natural fit for decoupled, scalable workflows.ProcessEverythingWebhookProfile), enabling tailored behavior for niche use cases (e.g., filtering specific repos or events).github_webhook_calls table) and exception handling provide audit trails and debugging hooks, critical for production reliability.issues.opened) and headers (e.g., X-GitHub-Event), simplifying validation.Route::githubWebhooks() abstracts routing complexity, though TPMs must ensure the endpoint is publicly accessible (e.g., no auth middleware).verify_signature (e.g., in dev) introduces security risks if misconfigured. TPMs must enforce this in production.failed_jobs table).pull_request events). Laravel’s default max_execution_time may need adjustment for heavy payloads.*) handlers simplify setup but may lead to bloated logic if overused. TPMs should balance specificity (e.g., issues.opened) vs. generality.GitHubWebhookCall) require careful versioning if extending the model.payload_hash).database driver).GITHUB_WEBHOOK_SECRET) be managed (e.g., Vault, env vars)?WebhookFailed exception)?GitHubWebhookCall model need extensions (e.g., soft deletes, additional fields)?push events)?database or redis drivers).redis).laravel-webhook-client: If bidirectional communication is needed (e.g., sending webhooks to GitHub).push, issues, workflow_run)?composer require spatie/laravel-github-webhooks.php artisan vendor:publish --tag=github-webhooks-config,migrations.GITHUB_WEBHOOK_SECRET in .env.routes/api.php:
Route::githubWebhooks('github/webhook');
https://your-app.com/github/webhook).push → trigger CI, issues → notify teams).// config/github-webhooks.php
'jobs' => [
'push' => \App\Jobs\GitHubWebhooks\TriggerCIJob::class,
'issues.opened' => \App\Jobs\GitHubWebhooks\NotifyTeamJob::class,
],
dd($webhookCall->payload()) in jobs.php artisan migrate.app/Console/Kernel.php:
$schedule->command('model:prune', ['--model' => \Spatie\GitHubWebhooks\Models\GitHubWebhookCall::class])
->daily();
php artisan queue:work).200 response). Use except in VerifyCsrfToken if needed.push events, another issues).push) and expand.*) handlers last (highest risk of missed edge cases).config/github-webhooks.php) reduces drift but requires discipline to update secrets (e.g., GITHUB_WEBHOOK_SECRET) across environments.failed_jobs table. TPMs should:
failed_jobs count (e.g., via Horizon or custom alerts).GitHubWebhookCall (e.g., adding columns) requires new migrations and zero-downtime deployment strategies (e.g., Laravel’s schema modifications).dd($webhookCall->payload()) in jobs or log payloads to a service like Datadog.GITHUB_WEBHOOK_SECRET matches GitHub’s settings. Test locally with verify_signature: false (temporarily).How can I help you explore Laravel packages today?