diff --git a/cli/cmd/project/connect_github.go b/cli/cmd/project/connect_github.go index 22fbe33d851..419ca9d457b 100644 --- a/cli/cmd/project/connect_github.go +++ b/cli/cmd/project/connect_github.go @@ -272,7 +272,7 @@ func ConnectGithubFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts vars, err := local.ParseDotenv(ctx, localProjectPath) if err != nil { ch.PrintfWarn("Failed to parse .env: %v\n", err) - } else { + } else if len(vars) > 0 { c, err := ch.Client() if err != nil { return err diff --git a/cli/cmd/project/deploy.go b/cli/cmd/project/deploy.go index b95b89be51e..1b323dfcd8f 100644 --- a/cli/cmd/project/deploy.go +++ b/cli/cmd/project/deploy.go @@ -197,7 +197,7 @@ func DeployWithUploadFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployO vars, err := local.ParseDotenv(ctx, localProjectPath) if err != nil { ch.PrintfWarn("Failed to parse .env: %v\n", err) - } else { + } else if len(vars) > 0 { _, err = adminClient.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ Organization: ch.Org, Project: opts.Name, @@ -256,7 +256,7 @@ func DeployWithUploadFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployO vars, err := local.ParseDotenv(ctx, localProjectPath) if err != nil { ch.PrintfWarn("Failed to parse .env: %v\n", err) - } else { + } else if len(vars) > 0 { _, err = adminClient.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ Organization: ch.Org, Project: opts.Name, diff --git a/cli/pkg/local/server.go b/cli/pkg/local/server.go index 963e7de1f7c..31eef9a84d8 100644 --- a/cli/pkg/local/server.go +++ b/cli/pkg/local/server.go @@ -396,13 +396,15 @@ func (s *Server) DeployProject(ctx context.Context, r *connect.Request[localv1.D if err != nil { return nil, fmt.Errorf("failed to parse .env: %w", err) } - _, err = c.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ - Organization: r.Msg.Org, - Project: r.Msg.ProjectName, - Variables: dotenv, - }) - if err != nil { - return nil, err + if len(dotenv) > 0 { + _, err = c.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ + Organization: r.Msg.Org, + Project: r.Msg.ProjectName, + Variables: dotenv, + }) + if err != nil { + return nil, err + } } return connect.NewResponse(&localv1.DeployProjectResponse{ @@ -457,13 +459,15 @@ func (s *Server) RedeployProject(ctx context.Context, r *connect.Request[localv1 if err != nil { return nil, fmt.Errorf("failed to parse .env: %w", err) } - _, err = c.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ - Organization: projResp.Project.OrgName, - Project: projResp.Project.Name, - Variables: dotenv, - }) - if err != nil { - return nil, err + if len(dotenv) > 0 { + _, err = c.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ + Organization: projResp.Project.OrgName, + Project: projResp.Project.Name, + Variables: dotenv, + }) + if err != nil { + return nil, err + } } // TODO : Add other update project fields