-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.go
54 lines (42 loc) · 947 Bytes
/
deploy.go
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
package main
import (
"github.com/spf13/cobra"
"log"
"path/filepath"
)
var deployCmd = &cobra.Command{
Use: "deploy",
Short: "deploy a site to BitBalloon",
Long: "deploys an existing site or creates a new site",
}
func init() {
deployCmd.Run = deploy
}
func deploy(cmd *cobra.Command, args []string) {
client := newClient()
var dir string
if len(args) > 0 {
dir = args[0]
} else {
dir = "."
}
path, err := filepath.Abs(dir)
if err != nil {
log.Fatalln("Bad directory path")
}
// Deploy
log.Printf("Deploying site: %v - dir: %v", SiteId, path)
site, _, err := client.Sites.Get(SiteId)
if err != nil {
log.Fatalf("Error during deploy: %v", err)
}
deploy, _, err := site.Deploys.Create(path)
if err != nil {
log.Fatalf("Deploy failed with error: ", err)
}
err = deploy.WaitForReady(0)
if err != nil {
log.Fatalf("Error dring site processing: ", err)
}
log.Println("Site deployed to", site.Url)
}