From a97521aba211ba973ffdf2b60ff50fa1b052933c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 3 Oct 2022 11:42:07 +0200 Subject: [PATCH] webhook: send 200 for ping and installation wh --- apps/api/src/routes/webhooks/github/handlers.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/webhooks/github/handlers.ts b/apps/api/src/routes/webhooks/github/handlers.ts index 215d3ec69..26c400737 100644 --- a/apps/api/src/routes/webhooks/github/handlers.ts +++ b/apps/api/src/routes/webhooks/github/handlers.ts @@ -66,13 +66,19 @@ export async function configureGitHubApp(request, reply) { } export async function gitHubEvents(request: FastifyRequest): Promise { try { - const allowedGithubEvents = ['push', 'pull_request']; + const allowedGithubEvents = ['push', 'pull_request', 'ping', 'installation']; const allowedActions = ['opened', 'reopened', 'synchronize', 'closed']; const githubEvent = request.headers['x-github-event']?.toString().toLowerCase(); const githubSignature = request.headers['x-hub-signature-256']?.toString().toLowerCase(); if (!allowedGithubEvents.includes(githubEvent)) { throw { status: 500, message: 'Event not allowed.' } } + if (githubEvent === 'ping') { + return { pong: 'cool' } + } + if (githubEvent === 'installation') { + return { status: 'cool' } + } let projectId, branch; const body = request.body if (githubEvent === 'push') {