2014-02-23 17:02:53 +00:00
|
|
|
package deploy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-09-08 06:08:35 +00:00
|
|
|
"github.com/drone/drone/plugin/condition"
|
2014-06-04 21:25:38 +00:00
|
|
|
"github.com/drone/drone/shared/build/buildfile"
|
2014-02-23 17:02:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Modulus struct {
|
|
|
|
Project string `yaml:"project,omitempty"`
|
|
|
|
Token string `yaml:"token,omitempty"`
|
2014-09-08 06:08:35 +00:00
|
|
|
|
|
|
|
Condition *condition.Condition `yaml:"when,omitempty"`
|
2014-02-23 17:02:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Modulus) Write(f *buildfile.Buildfile) {
|
2014-02-23 23:07:25 +00:00
|
|
|
f.WriteEnv("MODULUS_TOKEN", m.Token)
|
2014-02-23 17:02:53 +00:00
|
|
|
|
|
|
|
// Install the Modulus command line interface then deploy the configured
|
|
|
|
// project.
|
2014-02-23 23:07:25 +00:00
|
|
|
f.WriteCmdSilent("[ -f /usr/bin/sudo ] || npm install -g modulus")
|
|
|
|
f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo npm install -g modulus")
|
2014-02-23 23:10:01 +00:00
|
|
|
f.WriteCmd(fmt.Sprintf("modulus deploy -p '%s'", m.Project))
|
2014-02-23 17:02:53 +00:00
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
|
|
|
|
func (m *Modulus) GetCondition() *condition.Condition {
|
|
|
|
return m.Condition
|
|
|
|
}
|