GitHub
Trigger Nebutra workflows on GitHub events and sync issues, PRs, and deployments.
Overview
The GitHub integration lets you:
- Trigger workflows when GitHub events occur (push, PR opened, issue created)
- Create Linear issues or send Slack notifications from GitHub webhook events
- Link deployments to commits for traceability
Step 1: Create a GitHub App
- Go to GitHub → Settings → Developer settings → GitHub Apps → New GitHub App
- Set the webhook URL to:
https://api.nebutra.com/api/webhooks/github - Generate a webhook secret and copy it
- Subscribe to these events:
- Push
- Pull request
- Issues
- Deployment status
- Install the app on your repository
Step 2: Configure environment variables
GITHUB_APP_ID=123456
GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..."
GITHUB_WEBHOOK_SECRET=your_webhook_secretStep 3: Register the integration
In Settings → Integrations → GitHub → Connect, or via API:
await nebutra.integrations.github.configure({
orgId: "org_123",
repoOwner: "your-org",
repoName: "your-repo",
events: ["push", "pull_request", "deployment_status"],
});Step 4: Handle GitHub events
import { createHmac } from "crypto";
export async function POST(req: Request) {
const body = await req.text();
const sig = req.headers.get("x-hub-signature-256")!;
const event = req.headers.get("x-github-event")!;
// Verify signature
const expectedSig = `sha256=${createHmac("sha256", process.env.GITHUB_WEBHOOK_SECRET!)
.update(body)
.digest("hex")}`;
if (sig !== expectedSig) {
return new Response("Invalid signature", { status: 400 });
}
const payload = JSON.parse(body);
switch (event) {
case "push":
await handlePush(payload);
break;
case "pull_request":
if (payload.action === "opened") {
await handlePROpened(payload);
}
break;
case "deployment_status":
await handleDeploymentStatus(payload);
break;
}
return new Response("OK", { status: 200 });
}Use cases
Auto-create issues on deploy failure
async function handleDeploymentStatus(payload: any) {
if (payload.deployment_status.state !== "failure") return;
await nebutra.webhooks.sendEvent({
id: crypto.randomUUID(),
eventType: "deployment.failed",
payload: {
repo: payload.repository.full_name,
environment: payload.deployment.environment,
sha: payload.deployment.sha,
},
tenantId: "org_123",
timestamp: new Date().toISOString(),
});
}Notify Slack on PR merged
async function handlePROpened(payload: any) {
if (payload.action !== "closed" || !payload.pull_request.merged) return;
await slack.send({
channel: process.env.SLACK_CHANNEL_ID!,
text: `✅ PR merged: ${payload.pull_request.title} by @${payload.pull_request.user.login}`,
});
}Related
How is this guide?
Edit on GitHub
Last updated on