diff --git a/cli/cmd/deploy/deploy.go b/cli/cmd/deploy/deploy.go index 117e948aeb2..45bc1a13a62 100644 --- a/cli/cmd/deploy/deploy.go +++ b/cli/cmd/deploy/deploy.go @@ -24,6 +24,10 @@ func DeployCmd(ch *cmdutil.Helper) *cobra.Command { } } + if len(args) > 0 { + opts.GitPath = args[0] + } + if !upload && !github { confirmed, err := cmdutil.ConfirmPrompt("Enable automatic deploys to Rill Cloud from GitHub?", "", false) if err != nil { diff --git a/cli/cmd/project/connect_github.go b/cli/cmd/project/connect_github.go index 6f9e73e70b2..22fbe33d851 100644 --- a/cli/cmd/project/connect_github.go +++ b/cli/cmd/project/connect_github.go @@ -38,9 +38,12 @@ func GitPushCmd(ch *cmdutil.Helper) *cobra.Command { opts := &DeployOpts{} deployCmd := &cobra.Command{ - Use: "connect-github", + Use: "connect-github []", Short: "Deploy project to Rill Cloud by pulling project files from a git repository", RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.GitPath = args[0] + } return ConnectGithubFlow(cmd.Context(), ch, opts) }, } diff --git a/cli/cmd/project/deploy.go b/cli/cmd/project/deploy.go index 3b2a0f8e1cf..b95b89be51e 100644 --- a/cli/cmd/project/deploy.go +++ b/cli/cmd/project/deploy.go @@ -47,9 +47,12 @@ func DeployCmd(ch *cmdutil.Helper) *cobra.Command { opts := &DeployOpts{} deployCmd := &cobra.Command{ - Use: "deploy", + Use: "deploy []", Short: "Deploy project to Rill Cloud by uploading the project files", RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.GitPath = args[0] + } return DeployWithUploadFlow(cmd.Context(), ch, opts) }, } @@ -173,6 +176,7 @@ func DeployWithUploadFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployO return err } printer.ColorGreenBold.Printf("All files uploaded successfully.\n\n") + // Update the project // Silently ignores other flags like description etc which are handled with project update. res, err := adminClient.UpdateProject(ctx, &adminv1.UpdateProjectRequest{ @@ -188,6 +192,23 @@ func DeployWithUploadFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployO return fmt.Errorf("update project failed with error %w", err) } ch.Telemetry(ctx).RecordBehavioralLegacy(activity.BehavioralEventDeploySuccess) + + // Fetch vars from .env + vars, err := local.ParseDotenv(ctx, localProjectPath) + if err != nil { + ch.PrintfWarn("Failed to parse .env: %v\n", err) + } else { + _, err = adminClient.UpdateProjectVariables(ctx, &adminv1.UpdateProjectVariablesRequest{ + Organization: ch.Org, + Project: opts.Name, + Variables: vars, + }) + if err != nil { + ch.PrintfWarn("Failed to upload .env: %v\n", err) + } + } + + // Success ch.PrintfSuccess("Updated project \"%s/%s\".\n\n", ch.Org, res.Project.Name) return nil }