@@ -195,6 +195,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
195195
196196 const branch =
197197 options . env === "preview" ? getBranch ( { specified : options . branch , gitMeta } ) : undefined ;
198+
198199 if ( options . env === "preview" && ! branch ) {
199200 throw new Error (
200201 "Didn't auto-detect preview branch, so you need to specify one. Pass --branch <branch>."
@@ -318,10 +319,9 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
318319 }
319320
320321 const hasVarsToSync =
321- buildManifest . deploy . sync &&
322- ( ( buildManifest . deploy . sync . env && Object . keys ( buildManifest . deploy . sync . env ) . length > 0 ) ||
323- ( buildManifest . deploy . sync . parentEnv &&
324- Object . keys ( buildManifest . deploy . sync . parentEnv ) . length > 0 ) ) ;
322+ Object . keys ( buildManifest . deploy . sync ?. env || { } ) . length > 0 ||
323+ // Only sync parent variables if this is a branch environment
324+ ( branch && Object . keys ( buildManifest . deploy . sync ?. parentEnv || { } ) . length > 0 ) ;
325325
326326 if ( hasVarsToSync ) {
327327 const childVars = buildManifest . deploy . sync ?. env ?? { } ;
@@ -333,21 +333,22 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
333333 if ( ! options . skipSyncEnvVars ) {
334334 const $spinner = spinner ( ) ;
335335 $spinner . start ( `Syncing ${ numberOfEnvVars } env ${ vars } with the server` ) ;
336- const success = await syncEnvVarsWithServer (
336+
337+ const uploadResult = await syncEnvVarsWithServer (
337338 projectClient . client ,
338339 resolvedConfig . project ,
339340 options . env ,
340341 childVars ,
341342 parentVars
342343 ) ;
343344
344- if ( ! success ) {
345+ if ( ! uploadResult . success ) {
345346 await failDeploy (
346347 projectClient . client ,
347348 deployment ,
348349 {
349350 name : "SyncEnvVarsError" ,
350- message : `Failed to sync ${ numberOfEnvVars } env ${ vars } with the server` ,
351+ message : `Failed to sync ${ numberOfEnvVars } env ${ vars } with the server: ${ uploadResult . error } ` ,
351352 } ,
352353 "" ,
353354 $spinner
@@ -587,13 +588,11 @@ export async function syncEnvVarsWithServer(
587588 envVars : Record < string , string > ,
588589 parentEnvVars ?: Record < string , string >
589590) {
590- const uploadResult = await apiClient . importEnvVars ( projectRef , environmentSlug , {
591+ return await apiClient . importEnvVars ( projectRef , environmentSlug , {
591592 variables : envVars ,
592593 parentVariables : parentEnvVars ,
593594 override : true ,
594595 } ) ;
595-
596- return uploadResult . success ;
597596}
598597
599598async function failDeploy (
@@ -637,7 +636,7 @@ async function failDeploy(
637636 console . log ( lastFewLines ) ;
638637 }
639638 } else {
640- outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } . ` ) ;
639+ outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } ` ) ;
641640 }
642641 } ;
643642
0 commit comments