disable cache for public repo pull requests (for now)
This commit is contained in:
parent
3b020f75f6
commit
0c4c5d81a9
2 changed files with 14 additions and 0 deletions
|
@ -32,6 +32,7 @@ func setup(c *Context) error {
|
|||
Network: false,
|
||||
Privileged: false,
|
||||
Volumes: false,
|
||||
Caching: false,
|
||||
Whitelist: c.Plugins,
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,14 @@ func setup(c *Context) error {
|
|||
opts.Network = true
|
||||
opts.Privileged = true
|
||||
opts.Volumes = true
|
||||
opts.Caching = true
|
||||
}
|
||||
// if repository is public, and a pull request, disable
|
||||
// the cache.
|
||||
if c.Repo.Private == false &&
|
||||
c.Build.PullRequest != nil &&
|
||||
c.Build.PullRequest.Number != 0 {
|
||||
opts.Caching = false
|
||||
}
|
||||
|
||||
// inject the matrix parameters into the yaml
|
||||
|
|
|
@ -15,6 +15,7 @@ type Opts struct {
|
|||
Volumes bool
|
||||
Network bool
|
||||
Privileged bool
|
||||
Caching bool
|
||||
Whitelist []string
|
||||
}
|
||||
|
||||
|
@ -22,6 +23,7 @@ var DefaultOpts = &Opts{
|
|||
Volumes: false,
|
||||
Network: false,
|
||||
Privileged: false,
|
||||
Caching: true,
|
||||
Whitelist: []string{"plugins/*"},
|
||||
}
|
||||
|
||||
|
@ -86,6 +88,9 @@ func ParseSingle(raw string, opts *Opts, r *common.Repo) (*common.Config, error)
|
|||
transform.RemovePrivileged(conf)
|
||||
}
|
||||
transform.Repo(conf, r)
|
||||
if !opts.Caching {
|
||||
transform.RemoveVolumes(conf)
|
||||
}
|
||||
|
||||
// lint the yaml file
|
||||
err = Lint(conf)
|
||||
|
|
Loading…
Reference in a new issue