@@ -220,6 +220,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
220220
221221 const branch =
222222 options . env === "preview" ? getBranch ( { specified : options . branch , gitMeta } ) : undefined ;
223+
223224 if ( options . env === "preview" && ! branch ) {
224225 throw new Error (
225226 "Didn't auto-detect preview branch, so you need to specify one. Pass --branch <branch>."
@@ -352,10 +353,9 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
352353 }
353354
354355 const hasVarsToSync =
355- buildManifest . deploy . sync &&
356- ( ( buildManifest . deploy . sync . env && Object . keys ( buildManifest . deploy . sync . env ) . length > 0 ) ||
357- ( buildManifest . deploy . sync . parentEnv &&
358- Object . keys ( buildManifest . deploy . sync . parentEnv ) . length > 0 ) ) ;
356+ Object . keys ( buildManifest . deploy . sync ?. env || { } ) . length > 0 ||
357+ // Only sync parent variables if this is a branch environment
358+ ( branch && Object . keys ( buildManifest . deploy . sync ?. parentEnv || { } ) . length > 0 ) ;
359359
360360 if ( hasVarsToSync ) {
361361 const childVars = buildManifest . deploy . sync ?. env ?? { } ;
@@ -367,21 +367,22 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
367367 if ( ! options . skipSyncEnvVars ) {
368368 const $spinner = spinner ( ) ;
369369 $spinner . start ( `Syncing ${ numberOfEnvVars } env ${ vars } with the server` ) ;
370- const success = await syncEnvVarsWithServer (
370+
371+ const uploadResult = await syncEnvVarsWithServer (
371372 projectClient . client ,
372373 resolvedConfig . project ,
373374 options . env ,
374375 childVars ,
375376 parentVars
376377 ) ;
377378
378- if ( ! success ) {
379+ if ( ! uploadResult . success ) {
379380 await failDeploy (
380381 projectClient . client ,
381382 deployment ,
382383 {
383384 name : "SyncEnvVarsError" ,
384- message : `Failed to sync ${ numberOfEnvVars } env ${ vars } with the server` ,
385+ message : `Failed to sync ${ numberOfEnvVars } env ${ vars } with the server: ${ uploadResult . error } ` ,
385386 } ,
386387 "" ,
387388 $spinner
@@ -626,13 +627,11 @@ export async function syncEnvVarsWithServer(
626627 envVars : Record < string , string > ,
627628 parentEnvVars ?: Record < string , string >
628629) {
629- const uploadResult = await apiClient . importEnvVars ( projectRef , environmentSlug , {
630+ return await apiClient . importEnvVars ( projectRef , environmentSlug , {
630631 variables : envVars ,
631632 parentVariables : parentEnvVars ,
632633 override : true ,
633634 } ) ;
634-
635- return uploadResult . success ;
636635}
637636
638637async function failDeploy (
@@ -663,7 +662,7 @@ async function failDeploy(
663662 } . Full build logs have been saved to ${ logPath } `
664663 ) ;
665664 } else {
666- outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } . ` ) ;
665+ outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } ` ) ;
667666 }
668667 } ;
669668
0 commit comments