From c02ea4289e405585c34342e85bce0a8f94d08046 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 25 Jul 2022 19:55:17 +0000 Subject: [PATCH] fixes --- apps/api/src/routes/webhooks/github/handlers.ts | 4 ++-- apps/api/src/routes/webhooks/github/types.ts | 6 ++++++ apps/ui/src/routes/destinations/index.svelte | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/api/src/routes/webhooks/github/handlers.ts b/apps/api/src/routes/webhooks/github/handlers.ts index d8b4e7be8..74d53ecef 100644 --- a/apps/api/src/routes/webhooks/github/handlers.ts +++ b/apps/api/src/routes/webhooks/github/handlers.ts @@ -82,7 +82,7 @@ export async function gitHubEvents(request: FastifyRequest): Promi branch = body.ref.includes('/') ? body.ref.split('/')[2] : body.ref; } else if (githubEvent === 'pull_request') { projectId = body.pull_request.base.repo.id; - branch = body.pull_request.base.ref.includes('/') ? body.pull_request.base.ref.split('/')[2] : body.pull_request.base.ref; + branch = body.pull_request.head.ref.includes('/') ? body.pull_request.head.ref.split('/')[2] : body.pull_request.head.ref; } if (!projectId || !branch) { throw { status: 500, message: 'Cannot parse projectId or branch from the webhook?!' } @@ -154,7 +154,7 @@ export async function gitHubEvents(request: FastifyRequest): Promi } else if (githubEvent === 'pull_request') { const pullmergeRequestId = body.number; const pullmergeRequestAction = body.action; - const sourceBranch = body.pull_request.base.ref.includes('/') ? body.pull_request.base.ref.split('/')[2] : body.pull_request.base.ref; + const sourceBranch = body.pull_request.head.ref.includes('/') ? body.pull_request.head.ref.split('/')[2] : body.pull_request.head.ref; if (!allowedActions.includes(pullmergeRequestAction)) { throw { status: 500, message: 'Action not allowed.' } } diff --git a/apps/api/src/routes/webhooks/github/types.ts b/apps/api/src/routes/webhooks/github/types.ts index a8f5d3817..1c6f6f9f4 100644 --- a/apps/api/src/routes/webhooks/github/types.ts +++ b/apps/api/src/routes/webhooks/github/types.ts @@ -18,6 +18,12 @@ export interface GitHubEvents { repo: { id: string, } + }, + head: { + ref: string, + repo: { + id: string, + } } } } diff --git a/apps/ui/src/routes/destinations/index.svelte b/apps/ui/src/routes/destinations/index.svelte index a2b7900ae..cc6e59cdc 100644 --- a/apps/ui/src/routes/destinations/index.svelte +++ b/apps/ui/src/routes/destinations/index.svelte @@ -94,9 +94,9 @@ {#if destination.remoteEngine}