forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathup.go
More file actions
89 lines (73 loc) · 1.79 KB
/
Copy pathup.go
File metadata and controls
89 lines (73 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package cmd
import (
"context"
"fmt"
"time"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
)
func (h *Handler) Up(ctx context.Context, req *entity.CommandRequest) error {
var src string
if len(req.Args) == 0 {
src = "."
} else {
src = "./" + req.Args[0]
}
projectConfig, err := h.ctrl.GetProjectConfigs(ctx)
if err != nil {
return err
}
environmentName, err := req.Cmd.Flags().GetString("environment")
if err != nil {
return err
}
environment, err := h.getEnvironment(ctx, environmentName)
if err != nil {
return err
}
project, err := h.ctrl.GetProject(ctx, projectConfig.Project)
if err != nil {
return err
}
service, err := ui.PromptServices(project.Services)
if err != nil {
return err
}
ui.StartSpinner(&ui.SpinnerCfg{
Message: "Laying tracks in the clouds...",
})
res, err := h.ctrl.Upload(ctx, &entity.UploadRequest{
ProjectID: projectConfig.Project,
EnvironmentID: environment.Id,
ServiceID: service.ID,
RootDir: src,
})
if err != nil {
return err
} else {
ui.StopSpinner(fmt.Sprintf("☁️ Build logs available at %s\n", ui.GrayText(res.URL)))
}
detach, err := req.Cmd.Flags().GetBool("detach")
if err != nil {
return err
}
if detach {
return nil
}
for i := 0; i < 3; i++ {
err = h.ctrl.GetActiveBuildLogs(ctx, 0)
if err == nil {
break
}
time.Sleep(time.Duration(i) * 250 * time.Millisecond)
}
fmt.Printf("\n\n======= Build Completed ======\n\n")
err = h.ctrl.GetActiveDeploymentLogs(ctx, 1000)
if err != nil {
return err
}
fmt.Printf("☁️ Deployment logs available at %s\n", ui.GrayText(res.URL))
fmt.Printf("OR run `railway logs` to tail them here\n\n")
fmt.Printf("☁️ Deployment live at %s\n", ui.GrayText(h.ctrl.GetFullUrlFromStaticUrl(res.DeploymentDomain)))
return nil
}