-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.go
More file actions
41 lines (30 loc) · 815 Bytes
/
publish.go
File metadata and controls
41 lines (30 loc) · 815 Bytes
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
package main
import (
"github.com/spf13/cobra"
"log"
)
var publishCmd = &cobra.Command{
Use: "publish",
Short: "publish a deploy",
Long: "publish a deploy to make it the active deploy for a site",
}
var deployId string
func init() {
publishCmd.Run = publish
publishCmd.Flags().StringVarP(&deployId, "deploy", "d", "", "Deploy ID")
}
func publish(cmd *cobra.Command, args []string) {
client := newClient()
if deployId == "" {
log.Fatalln("No deploy id. Use --deploy=<id-of-deploy-to-publish>")
}
deploy, _, err := client.Deploys.Get(deployId)
if err != nil {
log.Fatalf("Could not load deploy: %v", err)
}
_, err = deploy.Publish()
if err != nil {
log.Fatalf("Failed to publish deploy: %v", err)
}
log.Printf("Deploy %v published at %v", deploy.SiteUrl)
}