From 5d9abcce6af95138e55c6e7ba60a0a805c3c0c7d Mon Sep 17 00:00:00 2001 From: maksim hodasevich Date: Fri, 17 Nov 2023 17:27:38 +0100 Subject: [PATCH] console.github response --- app/api/roll-out/route.ts | 6 ++++-- lib/services.ts | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/api/roll-out/route.ts b/app/api/roll-out/route.ts index b414d03..37eb7a5 100644 --- a/app/api/roll-out/route.ts +++ b/app/api/roll-out/route.ts @@ -28,7 +28,7 @@ export async function POST(request: Request) { }); if (projectData) { - await triggerGithubWorkflow({ + const result = await triggerGithubWorkflow({ sanityProjectId, sanityDatasetName, vercelProjectId: projectData.projectId, @@ -37,7 +37,9 @@ export async function POST(request: Request) { email, }); - return new Response('All steps were successful 🎉', { status: 200 }); + if (result === true) { + return new Response('All steps were successful 🎉', { status: 200 }); + } } } diff --git a/lib/services.ts b/lib/services.ts index 0ee144a..35017e5 100644 --- a/lib/services.ts +++ b/lib/services.ts @@ -154,11 +154,15 @@ export async function triggerGithubWorkflow({ }, ); + console.log(response.json()); + if (response.status === 401) { throw new Error('Invalid github token'); } console.log('Github workflow triggered...✅'); + + return true; } catch (e) { console.log(e); }