diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index 0edc0a7..b4d4408 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -221,3 +221,8 @@ properties: description: Target platforms for build. type: list required: false + + labels: + description: Labels to add to the image. + type: list + required: false diff --git a/cmd/drone-docker-buildx/config.go b/cmd/drone-docker-buildx/config.go index 4bcb574..f259c70 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/drone-docker-buildx/config.go @@ -297,5 +297,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Destination: &settings.Build.Platforms, Category: category, }, + &cli.StringSliceFlag{ + Name: "labels", + EnvVars: []string{"PLUGIN_LABELS"}, + Usage: "labels to add to image", + Destination: &settings.Build.Labels, + Category: category, + }, } } diff --git a/plugin/docker.go b/plugin/docker.go index 557dae2..bbbdd69 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.Labels.Value() { + args = append(args, "--label", arg) + } + return exec.Command(dockerExe, args...) } diff --git a/plugin/impl.go b/plugin/impl.go index 809a232..1550500 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -61,6 +61,7 @@ type Build struct { Quiet bool // Docker build quiet Output string // Docker build output folder NamedContext cli.StringSlice // Docker build named context + Labels cli.StringSlice // Docker build labels } // Settings for the Plugin.