@@ -220,6 +220,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
220
220
221
221
const branch =
222
222
options . env === "preview" ? getBranch ( { specified : options . branch , gitMeta } ) : undefined ;
223
+
223
224
if ( options . env === "preview" && ! branch ) {
224
225
throw new Error (
225
226
"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) {
352
353
}
353
354
354
355
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 ) ;
359
359
360
360
if ( hasVarsToSync ) {
361
361
const childVars = buildManifest . deploy . sync ?. env ?? { } ;
@@ -367,21 +367,22 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
367
367
if ( ! options . skipSyncEnvVars ) {
368
368
const $spinner = spinner ( ) ;
369
369
$spinner . start ( `Syncing ${ numberOfEnvVars } env ${ vars } with the server` ) ;
370
- const success = await syncEnvVarsWithServer (
370
+
371
+ const uploadResult = await syncEnvVarsWithServer (
371
372
projectClient . client ,
372
373
resolvedConfig . project ,
373
374
options . env ,
374
375
childVars ,
375
376
parentVars
376
377
) ;
377
378
378
- if ( ! success ) {
379
+ if ( ! uploadResult . success ) {
379
380
await failDeploy (
380
381
projectClient . client ,
381
382
deployment ,
382
383
{
383
384
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 } ` ,
385
386
} ,
386
387
"" ,
387
388
$spinner
@@ -626,13 +627,11 @@ export async function syncEnvVarsWithServer(
626
627
envVars : Record < string , string > ,
627
628
parentEnvVars ?: Record < string , string >
628
629
) {
629
- const uploadResult = await apiClient . importEnvVars ( projectRef , environmentSlug , {
630
+ return await apiClient . importEnvVars ( projectRef , environmentSlug , {
630
631
variables : envVars ,
631
632
parentVariables : parentEnvVars ,
632
633
override : true ,
633
634
} ) ;
634
-
635
- return uploadResult . success ;
636
635
}
637
636
638
637
async function failDeploy (
@@ -663,7 +662,7 @@ async function failDeploy(
663
662
} . Full build logs have been saved to ${ logPath } `
664
663
) ;
665
664
} else {
666
- outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } . ` ) ;
665
+ outro ( `${ chalkError ( `${ prefix } :` ) } ${ error . message } ` ) ;
667
666
}
668
667
} ;
669
668
0 commit comments