fix: fix auto_tag behavior to avoid unexpected publishing

This commit is contained in:
Robert Kaussow 2022-01-11 21:48:50 +01:00
parent a3e33afdf6
commit 221c9e6a73
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
3 changed files with 3 additions and 4 deletions

View File

@ -117,7 +117,6 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
Name: "tags", Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"}, EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
Usage: "sets repository tags to use for the image", Usage: "sets repository tags to use for the image",
Value: cli.NewStringSlice([]string{"latest"}...),
FilePath: ".tags", FilePath: ".tags",
Destination: &settings.Build.Tags, Destination: &settings.Build.Tags,
}, },

View File

@ -84,7 +84,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
} }
args = append(args, build.Context) args = append(args, build.Context)
if !dryrun { if !dryrun && len(build.Tags.Value()) > 0 {
args = append(args, "--push") args = append(args, "--push")
} }
if build.Compress { if build.Compress {

View File

@ -87,12 +87,12 @@ func (p *Plugin) Validate() error {
p.settings.Build.TagsSuffix, p.settings.Build.TagsSuffix,
) )
if err != nil { if err != nil {
logrus.Printf("cannot build docker image for %s, invalid semantic version", p.settings.Build.Ref) logrus.Printf("cannot generate tags from %s, invalid semantic version", p.settings.Build.Ref)
return err return err
} }
p.settings.Build.Tags = *cli.NewStringSlice(tag...) p.settings.Build.Tags = *cli.NewStringSlice(tag...)
} else { } else {
logrus.Printf("skipping automated docker build for %s", p.settings.Build.Ref) logrus.Printf("skip auto-tagging for %s, not on default branch or tag", p.settings.Build.Ref)
return nil return nil
} }
} }