Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
begelundmuller committed Jan 16, 2025
1 parent 76444a2 commit efeeaba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion cli/cmd/project/connect_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ func GitPushCmd(ch *cmdutil.Helper) *cobra.Command {
opts := &DeployOpts{}

deployCmd := &cobra.Command{
Use: "connect-github",
Use: "connect-github [<path>]",
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)
},
}
Expand Down
23 changes: 22 additions & 1 deletion cli/cmd/project/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ func DeployCmd(ch *cmdutil.Helper) *cobra.Command {
opts := &DeployOpts{}

deployCmd := &cobra.Command{
Use: "deploy",
Use: "deploy [<path>]",
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)
},
}
Expand Down Expand Up @@ -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{
Expand All @@ -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
}
Expand Down

0 comments on commit efeeaba

Please sign in to comment.