diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index b4d4408..2735f9e 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -117,6 +117,14 @@ properties: type: string required: false + extra_tags: + description: | + Set additional tags to be used for the image. Additional tags can also be loaded from an `.extratags` file. This function can be used + to push images to multiple registries at once. Therefore, it is necessary to use the `config` flag to provide a configuration file + that contains the authentication information for all used registries. + type: list + required: false + build_args: description: Ccustom build arguments to pass to the build. type: list diff --git a/cmd/drone-docker-buildx/config.go b/cmd/drone-docker-buildx/config.go index f259c70..66b5dac 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/drone-docker-buildx/config.go @@ -158,6 +158,14 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Destination: &settings.Build.TagsSuffix, Category: category, }, + &cli.StringSliceFlag{ + Name: "extra.tags", + EnvVars: []string{"PLUGIN_EXTRA_TAGS"}, + Usage: "additional tags to use for the image including registry", + FilePath: ".extratags", + Destination: &settings.Build.ExtraTags, + Category: category, + }, &cli.StringSliceFlag{ Name: "args", EnvVars: []string{"PLUGIN_BUILD_ARGS"}, diff --git a/plugin/docker.go b/plugin/docker.go index bbbdd69..5ece2c3 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -123,6 +123,10 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg)) } + for _, arg := range build.ExtraTags.Value() { + args = append(args, "-t", arg) + } + for _, arg := range build.Labels.Value() { args = append(args, "--label", arg) } diff --git a/plugin/impl.go b/plugin/impl.go index 1550500..296a86d 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -47,6 +47,7 @@ type Build struct { TagsAuto bool // Docker build auto tag TagsSuffix string // Docker build tags with suffix Tags cli.StringSlice // Docker build tags + ExtraTags cli.StringSlice // Docker build tags including registry Platforms cli.StringSlice // Docker build target platforms Args cli.StringSlice // Docker build args ArgsEnv cli.StringSlice // Docker build args from env