diff --git a/plugin/plugin.go b/plugin/plugin.go index 4fd66d5..6def189 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -26,6 +26,7 @@ type Args struct { Folder string `envconfig:"PLUGIN_FOLDER"` SshKey string `envconfig:"PLUGIN_SSH_KEY"` GitRemote string `envconfig:"PLUGIN_GIT_REMOTE"` + GitBranch string `envconfig:"PLUGIN_GIT_BRANCH"` GitRemoteFromDrone string `envconfig:"DRONE_GIT_SSH_URL"` } @@ -87,6 +88,10 @@ func checkArgs(args *Args) error { args.GitRemote = args.GitRemoteFromDrone } + if args.GitBranch == "" { + args.GitBranch = BRANCH_NAME + } + return nil } @@ -127,7 +132,7 @@ func copyFiles(args Args) error { func initRepo(args Args) error { cmd := exec.Command( "git", - "init", "-b", BRANCH_NAME, "/tmp/pages") + "init", "-b", args.GitBranch, "/tmp/pages") if err := execute(cmd); err != nil { return err @@ -149,7 +154,7 @@ func doCommit(args Args) error { } func push(args Args) error { - return execute(repo.RemotePushNamedBranch(args.GitRemote, BRANCH_NAME, BRANCH_NAME, true, false)) + return execute(repo.RemotePushNamedBranch(args.GitRemote, args.GitBranch, args.GitBranch, true, false)) } func execute(cmd *exec.Cmd) error {