-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypescript
More file actions
41 lines (34 loc) · 1003 Bytes
/
Copy pathtypescript
File metadata and controls
41 lines (34 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { NextApiRequest, NextApiResponse } from 'next';
import { createNodeMiddleware, createProbot } from 'probot';
const probot = createProbot();
const app = probot.load(async (app) => {
app.on('push', async (context) => {
// Handle push events
const repo = context.repo();
const commit = context.payload.head_commit;
// Log the push event
console.log(`New push in ${repo.owner}/${repo.repo}: ${commit.message}`);
});
app.on('pull_request', async (context) => {
// Handle pull request events
const pr = context.payload.pull_request;
console.log(`New PR: ${pr.title}`);
});
});
const middleware = createNodeMiddleware(app);
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
await middleware(req, res);
} catch (error) {
console.error('Webhook error:', error);
res.status(500).json({ error: 'Webhook processing failed' });
}
}
export const config = {
api: {
bodyParser: false
}
};