1
0
mirror of https://github.com/drone/drone-cli.git synced 2025-09-07 01:11:56 +02:00

added deploy fun

This commit is contained in:
Brad Rydzewski 2016-03-28 23:57:34 -07:00
parent 0c0e049ef0
commit 7434da77aa
2 changed files with 51 additions and 0 deletions

50
drone/deploy.go Normal file

@ -0,0 +1,50 @@
package main
import (
"fmt"
"strconv"
"github.com/codegangsta/cli"
"github.com/drone/drone-go/drone"
)
var DeployCmd = cli.Command{
Name: "deploy",
Usage: "deploy code",
Action: func(c *cli.Context) {
handle(c, deployCmd)
},
}
func deployCmd(c *cli.Context, client drone.Client) error {
var (
nameParam = c.Args().Get(0)
numParam = c.Args().Get(1)
err error
owner string
name string
num int
)
num, err = strconv.Atoi(numParam)
if err != nil {
return fmt.Errorf("Invalid or missing build number")
}
owner, name, err = parseRepo(nameParam)
if err != nil {
return err
}
build, err := client.Build(owner, name, num)
if err != nil {
return err
}
if build.Event == drone.EventPull {
return fmt.Errorf("Cannot trigger a pull request deployment")
}
// client.BuildFork(owner, name, num)
return nil
}

@ -34,6 +34,7 @@ func main() {
app.Commands = []cli.Command{
BuildCmd,
DeployCmd,
RepoCmd,
ExecCmd,
MachineCmd,