Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dispatch #218

Merged
merged 2 commits into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 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
await dispatchWorkflowByPath(platformReleaseRef, process.env.NEXT_PUBLIC_APP_STAGE === 'production' ? GITHUB_ACTION_WORKFLOW_FILE_PATH_PRODUCTION : GITHUB_ACTION_WORKFLOW_FILE_PATH_STAGING);
// 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