@@ -41,6 +41,7 @@ import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
4141import { ProjectSettingsService } from "~/services/projectSettings.server" ;
4242import { logger } from "~/services/logger.server" ;
4343import { triggerInitialDeployment } from "~/services/platform.v3.server" ;
44+ import { VercelIntegrationService } from "~/services/vercelIntegration.server" ;
4445import { requireUserId } from "~/services/session.server" ;
4546import {
4647 githubAppInstallPath ,
@@ -210,16 +211,22 @@ export async function action({ request, params }: ActionFunctionArgs) {
210211 ) ;
211212
212213 if ( resultOrFail . isOk ( ) ) {
213- // Trigger initial deployment for marketplace flows now that GitHub is connected
214- if ( redirectUrl ) {
215- try {
216- if ( redirectUrl . includes ( "origin=marketplace" ) ) {
217- await triggerInitialDeployment ( projectId , { environment : "prod" } ) ;
218- }
219- } catch ( error ) {
220- logger . error ( "Invalid redirect URL, skipping initial deployment trigger" , { redirectUrl, error } ) ;
221- // Invalid redirectUrl, skip initial deployment check
214+ // Trigger initial deployment for marketplace flows now that GitHub is connected.
215+ // We check the persisted onboardingOrigin on the Vercel integration rather than
216+ // the redirectUrl, because the redirect URL loses the marketplace context when
217+ // the user installs the GitHub App for the first time (full-page redirect cycle).
218+ try {
219+ const vercelService = new VercelIntegrationService ( ) ;
220+ const vercelIntegration = await vercelService . getVercelProjectIntegration ( projectId ) ;
221+ if (
222+ vercelIntegration ?. parsedIntegrationData . onboardingCompleted &&
223+ vercelIntegration . parsedIntegrationData . onboardingOrigin === "marketplace"
224+ ) {
225+ logger . info ( "Marketplace flow detected, triggering initial deployment" , { projectId } ) ;
226+ await triggerInitialDeployment ( projectId , { environment : "prod" } ) ;
222227 }
228+ } catch ( error ) {
229+ logger . error ( "Failed to check Vercel integration or trigger initial deployment" , { projectId, error } ) ;
223230 }
224231
225232 return redirectWithMessage (
0 commit comments