github.com/marinho/drone@v0.2.1-0.20140504195434-d3ba962e89a7/pkg/plugin/deploy/heroku.go (about) 1 package deploy 2 3 import ( 4 "fmt" 5 "github.com/drone/drone/pkg/build/buildfile" 6 ) 7 8 type Heroku struct { 9 App string `yaml:"app,omitempty"` 10 Force bool `yaml:"force,omitempty"` 11 Branch string `yaml:"branch,omitempty"` 12 } 13 14 func (h *Heroku) Write(f *buildfile.Buildfile) { 15 // get the current commit hash 16 f.WriteCmdSilent("COMMIT=$(git rev-parse HEAD)") 17 18 // set the git user and email based on the individual 19 // that made the commit. 20 f.WriteCmdSilent("git config --global user.name $(git --no-pager log -1 --pretty=format:'%an')") 21 f.WriteCmdSilent("git config --global user.email $(git --no-pager log -1 --pretty=format:'%ae')") 22 23 // add heroku as a git remote 24 f.WriteCmd(fmt.Sprintf("git remote add heroku git@heroku.com:%s.git", h.App)) 25 26 switch h.Force { 27 case true: 28 // this is useful when the there are artifacts generated 29 // by the build script, such as less files converted to css, 30 // that need to be deployed to Heroku. 31 f.WriteCmd(fmt.Sprintf("git add -A")) 32 f.WriteCmd(fmt.Sprintf("git commit -m 'adding build artifacts'")) 33 f.WriteCmd(fmt.Sprintf("git push heroku $COMMIT:master --force")) 34 case false: 35 // otherwise we just do a standard git push 36 f.WriteCmd(fmt.Sprintf("git push heroku $COMMIT:master")) 37 } 38 }