2014-02-07 10:10:01 +00:00
|
|
|
package publish
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/drone/drone/pkg/build/buildfile"
|
2014-04-29 02:28:07 +00:00
|
|
|
"github.com/drone/drone/pkg/build/repo"
|
2014-02-07 10:10:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Publish stores the configuration details
|
|
|
|
// for publishing build artifacts when
|
|
|
|
// a Build has succeeded
|
|
|
|
type Publish struct {
|
2014-03-29 22:18:25 +00:00
|
|
|
S3 *S3 `yaml:"s3,omitempty"`
|
2014-03-26 13:07:16 +00:00
|
|
|
Swift *Swift `yaml:"swift,omitempty"`
|
2014-03-29 22:18:25 +00:00
|
|
|
PyPI *PyPI `yaml:"pypi,omitempty"`
|
2014-05-04 17:29:51 +00:00
|
|
|
NPM *NPM `yaml:"npm,omitempty"`
|
2014-02-07 10:10:01 +00:00
|
|
|
}
|
|
|
|
|
2014-04-29 02:28:07 +00:00
|
|
|
func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
|
|
|
// S3
|
|
|
|
if p.S3 != nil && (len(p.S3.Branch) == 0 || (len(p.S3.Branch) > 0 && r.Branch == p.S3.Branch)) {
|
2014-02-07 10:10:01 +00:00
|
|
|
p.S3.Write(f)
|
|
|
|
}
|
2014-04-29 02:28:07 +00:00
|
|
|
|
|
|
|
// Swift
|
|
|
|
if p.Swift != nil && (len(p.Swift.Branch) == 0 || (len(p.Swift.Branch) > 0 && r.Branch == p.Swift.Branch)) {
|
2014-03-26 13:07:16 +00:00
|
|
|
p.Swift.Write(f)
|
|
|
|
}
|
2014-04-29 02:28:07 +00:00
|
|
|
|
|
|
|
// PyPI
|
|
|
|
if p.PyPI != nil && (len(p.PyPI.Branch) == 0 || (len(p.PyPI.Branch) > 0 && r.Branch == p.PyPI.Branch)) {
|
2014-03-28 05:43:58 +00:00
|
|
|
p.PyPI.Write(f)
|
|
|
|
}
|
2014-05-04 17:29:51 +00:00
|
|
|
|
|
|
|
// NPM
|
|
|
|
if p.NPM != nil && (len(p.NPM.Branch) == 0 || (len(p.NPM.Branch) > 0 && r.Branch == p.NPM.Branch)) {
|
|
|
|
p.NPM.Write(f)
|
|
|
|
}
|
2014-02-07 10:10:01 +00:00
|
|
|
}
|