Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 0bd2634

Browse files
feat: add extra_tags option to set tags including additional registries (#134)
1 parent 4171f3d commit 0bd2634

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

_docs/data/data.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ properties:
117117
type: string
118118
required: false
119119

120+
extra_tags:
121+
description: |
122+
Set additional tags to be used for the image. Additional tags can also be loaded from an `.extratags` file. This function can be used
123+
to push images to multiple registries at once. Therefore, it is necessary to use the `config` flag to provide a configuration file
124+
that contains the authentication information for all used registries.
125+
type: list
126+
required: false
127+
120128
build_args:
121129
description: Ccustom build arguments to pass to the build.
122130
type: list

cmd/drone-docker-buildx/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
158158
Destination: &settings.Build.TagsSuffix,
159159
Category: category,
160160
},
161+
&cli.StringSliceFlag{
162+
Name: "extra.tags",
163+
EnvVars: []string{"PLUGIN_EXTRA_TAGS"},
164+
Usage: "additional tags to use for the image including registry",
165+
FilePath: ".extratags",
166+
Destination: &settings.Build.ExtraTags,
167+
Category: category,
168+
},
161169
&cli.StringSliceFlag{
162170
Name: "args",
163171
EnvVars: []string{"PLUGIN_BUILD_ARGS"},

plugin/docker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
123123
args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg))
124124
}
125125

126+
for _, arg := range build.ExtraTags.Value() {
127+
args = append(args, "-t", arg)
128+
}
129+
126130
for _, arg := range build.Labels.Value() {
127131
args = append(args, "--label", arg)
128132
}

plugin/impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Build struct {
4747
TagsAuto bool // Docker build auto tag
4848
TagsSuffix string // Docker build tags with suffix
4949
Tags cli.StringSlice // Docker build tags
50+
ExtraTags cli.StringSlice // Docker build tags including registry
5051
Platforms cli.StringSlice // Docker build target platforms
5152
Args cli.StringSlice // Docker build args
5253
ArgsEnv cli.StringSlice // Docker build args from env

0 commit comments

Comments
 (0)