Open sourabhrathourr opened 1 month ago
This documentation covers the setup and handling of GitHub App installations and webhooks in a Next.js application using Drizzle ORM and Neon Database.
export const installations = pgTable('installation', { id: text('id').primaryKey(), userId: text('userId') .notNull() .references(() => users.id, { onDelete: 'cascade' }), installationId: text('installationId').notNull(), accountName: text('accountName').notNull(), repositoryIds: text('repositoryIds').array(), createdAt: timestamp('createdAt').defaultNow(), updatedAt: timestamp('updatedAt').defaultNow(), })
DATABASE_URL=your_neon_db_url GITHUB_WEBHOOK_SECRET=your_webhook_secret NEXT_PUBLIC_GITHUB_APP_NAME=your_github_app_name GITHUB_APP_ID=your_app_id GITHUB_APP_PRIVATE_KEY="your_private_key"
https://your-domain.com/api/github/webhook
# Start development server yarn dev # Start ngrok tunnel (for local development) yarn tunnel
The webhook handler (app/api/github/webhook/route.ts) processes GitHub App installation events and manages repository connections:
app/api/github/webhook/route.ts
created
added/removed
The webhook handler includes comprehensive error handling for:
PER-38 feat: add feature to let users connect their repositories with perlify
GitHub App Installation & Webhook Integration Documentation
Overview
This documentation covers the setup and handling of GitHub App installations and webhooks in a Next.js application using Drizzle ORM and Neon Database.
Database Schema
Required Environment Variables
Installation Steps
https://your-domain.com/api/github/webhook
Webhook Handler Implementation
The webhook handler (
app/api/github/webhook/route.ts
) processes GitHub App installation events and manages repository connections:created
: Creates new installation recordadded/removed
: Updates repository listTechnical Notes
Error Handling
The webhook handler includes comprehensive error handling for:
API Response Codes
References