mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
implemented tsuru deploy plugin.
This commit is contained in:
parent
3b3da0424e
commit
6ccc1729fb
2 changed files with 42 additions and 0 deletions
|
@ -18,6 +18,7 @@ type Deploy struct {
|
||||||
Nodejitsu *Nodejitsu `yaml:"nodejitsu,omitempty"`
|
Nodejitsu *Nodejitsu `yaml:"nodejitsu,omitempty"`
|
||||||
Openshift *Openshift `yaml:"openshift,omitempty"`
|
Openshift *Openshift `yaml:"openshift,omitempty"`
|
||||||
SSH *SSH `yaml:"ssh,omitempty"`
|
SSH *SSH `yaml:"ssh,omitempty"`
|
||||||
|
Tsuru *Tsuru `yaml:"tsuru,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Deploy) Write(f *buildfile.Buildfile) {
|
func (d *Deploy) Write(f *buildfile.Buildfile) {
|
||||||
|
@ -51,4 +52,7 @@ func (d *Deploy) Write(f *buildfile.Buildfile) {
|
||||||
if d.SSH != nil {
|
if d.SSH != nil {
|
||||||
d.SSH.Write(f)
|
d.SSH.Write(f)
|
||||||
}
|
}
|
||||||
|
if d.Tsuru != nil {
|
||||||
|
d.Tsuru.Write(f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
38
pkg/plugin/deploy/tsuru.go
Normal file
38
pkg/plugin/deploy/tsuru.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/drone/drone/pkg/build/buildfile"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Tsuru struct {
|
||||||
|
Force bool `yaml:"force,omitempty"`
|
||||||
|
Branch string `yaml:"branch,omitempty"`
|
||||||
|
Remote string `yaml:"remote,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Tsuru) Write(f *buildfile.Buildfile) {
|
||||||
|
// get the current commit hash
|
||||||
|
f.WriteCmdSilent("COMMIT=$(git rev-parse HEAD)")
|
||||||
|
|
||||||
|
// set the git user and email based on the individual
|
||||||
|
// that made the commit.
|
||||||
|
f.WriteCmdSilent("git config --global user.name $(git --no-pager log -1 --pretty=format:'%an')")
|
||||||
|
f.WriteCmdSilent("git config --global user.email $(git --no-pager log -1 --pretty=format:'%ae')")
|
||||||
|
|
||||||
|
// add tsuru as a git remote
|
||||||
|
f.WriteCmd(fmt.Sprintf("git remote add tsuru %s", h.Remote))
|
||||||
|
|
||||||
|
switch h.Force {
|
||||||
|
case true:
|
||||||
|
// this is useful when the there are artifacts generated
|
||||||
|
// by the build script, such as less files converted to css,
|
||||||
|
// that need to be deployed to Tsuru.
|
||||||
|
f.WriteCmd(fmt.Sprintf("git add -A"))
|
||||||
|
f.WriteCmd(fmt.Sprintf("git commit -m 'adding build artifacts'"))
|
||||||
|
f.WriteCmd(fmt.Sprintf("git push tsuru $COMMIT:master --force"))
|
||||||
|
case false:
|
||||||
|
// otherwise we just do a standard git push
|
||||||
|
f.WriteCmd(fmt.Sprintf("git push tsuru $COMMIT:master"))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue