Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions __mock__/team-projects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"team-projects": {
"title": "Team Projects",
"description": "This visualization showcases the work in progress of active projects at IXT",
"sensors": {
"github": {
"values": {
"project-1": {
"title": "Project 1",
"logo": "https://avatars.githubusercontent.com/u/9919?s=200&v=4",
"pullRequests": {
"pr_id_1": {
"title": "Feature: Add user authentication",
"description": "Implementing Firebase Auth",
"author": "user_123",
"createdAt": 1704537600000,
"status": "open",
"sourceBranch": "feature/auth",
"targetBranch": "main",
"commits": {
"commit_1": {
"hash": "abc123",
"message": "Initial auth setup",
"timestamp": 1704537600000
}
},
"checks": {
"check_1": {
"name": "Unit Tests",
"status": "passed",
"timestamp": 1704537700000,
"type": "automatic"
},
"check_2": {
"name": "Code Review",
"status": "pending",
"reviewerId": "user_456",
"type": "manual"
}
},
"timeline": {
"event_1": {
"type": "pr_created",
"timestamp": 1704537600000,
"actor": "user_123"
},
"event_2": {
"type": "check_completed",
"checkId": "check_1",
"timestamp": 1704537700000,
"status": "passed"
}
},
"reviewers": {
"user_456": {
"status": "pending",
"assignedAt": 1704537650000
}
}
}
},
"branches": {
"main": {
"lastCommit": "def456",
"lastUpdated": 1704537500000
},
"feature/auth": {
"lastCommit": "abc123",
"lastUpdated": 1704537600000
}
},
"users": {
"user_123": {
"name": "John Doe",
"email": "john@example.com",
"activePRs": {
"pr_id_1": true
}
},
"user_456": {
"name": "Jane Smith",
"email": "jane@example.com",
"assignedReviews": {
"pr_id_1": true
}
}
}
},
"project-2": {
"title": "Project 2",
"logo": "https://avatars.githubusercontent.com/u/9919?s=200&v=4",
"pullRequests": {
"pr_id_1": {
"title": "Feature: Add user authentication",
"description": "Implementing Firebase Auth",
"author": "user_123",
"createdAt": 1704537600000,
"status": "open",
"sourceBranch": "feature/auth",
"targetBranch": "main",
"commits": {
"commit_1": {
"hash": "abc123",
"message": "Initial auth setup",
"timestamp": 1704537600000
}
},
"checks": {
"check_1": {
"name": "Unit Tests",
"status": "passed",
"timestamp": 1704537700000,
"type": "automatic"
},
"check_2": {
"name": "Code Review",
"status": "pending",
"reviewerId": "user_456",
"type": "manual"
}
},
"timeline": {
"event_1": {
"type": "pr_created",
"timestamp": 1704537600000,
"actor": "user_123"
},
"event_2": {
"type": "check_completed",
"checkId": "check_1",
"timestamp": 1704537700000,
"status": "passed"
}
},
"reviewers": {
"user_456": {
"status": "pending",
"assignedAt": 1704537650000
}
}
}
},
"branches": {
"main": {
"lastCommit": "def456",
"lastUpdated": 1704537500000
},
"feature/auth": {
"lastCommit": "abc123",
"lastUpdated": 1704537600000
}
},
"users": {
"user_123": {
"name": "John Doe",
"email": "john@example.com",
"activePRs": {
"pr_id_1": true
}
},
"user_456": {
"name": "Jane Smith",
"email": "jane@example.com",
"assignedReviews": {
"pr_id_1": true
}
}
}
}
}
}
}
}
}
6 changes: 6 additions & 0 deletions app/api/github/events/projects/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { projectSync } from '@/server/github/syncs';
import { verifyGitHubRequest } from '@/server/security';
import { createError } from '@/utils/error-handling';
import {
Expand All @@ -10,6 +11,7 @@ import {
PullRequestEvent,
PullRequestReviewEvent,
PushEvent,
Repository,
RepositoryEvent,
WebhookEventMap,
WebhookEventName,
Expand All @@ -30,6 +32,10 @@ export const POST = async (req: NextRequest) => {
const body = JSON.parse(rawBody) as WebhookEventMap[WebhookEventName];
const event = req.headers.get('x-github-event') as WebhookEventName;

if (event !== 'ping' && 'repository' in body) {
await projectSync(body.repository as Repository);
}

switch (event) {
case 'ping': {
const pingEvent = body as PingEvent;
Expand Down