Skip to content

Commit

Permalink
Attempt to redirect after dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Nov 27, 2020
1 parent c046ffc commit d0be70c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/api/startVercelDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type EndpointRequest = NextApiRequest & {
/**
* Url to redirect to, once the deployment has been triggered.
*
* Will return early, not waiting for the actual deployment to be done, will not know whether the trigger was successful either.
* Will not wait for the actual deployment to be done, will not return whether the trigger was successful either.
*
* XXX We can't wait for the deployment to be performed by Vercel, as it'd definitely be longer than the maximum allowed serverless function running time (10-60sec depending on your Vercel plan).
* Thus, we redirect as early as possible and don't wait for any kind of feedback.
Expand Down Expand Up @@ -149,11 +149,12 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse)
return redirect(res, redirectTo, statusCode);
}

// Redirect the end-user early, as we don't need/want to wait for the dispatch to be triggered
redirect(res, redirectTo, statusCode);

// Dispatch the GitHub Actions workflow, which will then trigger the Vercel deployment
// XXX We don't await for the processing to be done
dispatchWorkflowByPath(platformReleaseRef, process.env.NEXT_PUBLIC_APP_STAGE === 'production' ? GITHUB_ACTION_WORKFLOW_FILE_PATH_PRODUCTION : GITHUB_ACTION_WORKFLOW_FILE_PATH_STAGING);

// Redirect the end-user
redirect(res, redirectTo, statusCode);
} catch (e) {
Sentry.captureException(e);
logger.error(e.message);
Expand Down

1 comment on commit d0be70c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.