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
67 lines (57 loc) · 1.47 KB
/
Copy pathup.go
File metadata and controls
67 lines (57 loc) · 1.47 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
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 {
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
}
ui.StartSpinner(&ui.SpinnerCfg{
Message: "Laying tracks in the clouds...",
})
res, err := h.ctrl.Upload(ctx, &entity.UploadRequest{
ProjectID: projectConfig.Project,
EnvironmentID: environment.Id,
})
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
}