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

Commit ee13dd8

Browse files
authored
feat: add output option to set the export action for build results (#71)
1 parent 25c0575 commit ee13dd8

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

_docs/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ pull_image
142142
compress
143143
: enables compression og the build context using gzip
144144

145+
output
146+
: sets output folder for build artifacts (format: `path` or `type=TYPE[,KEY=VALUE]`)
147+
145148
repo
146149
: sets repository name for the image
147150

cmd/drone-docker-buildx/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
150150
Usage: "enables suppression of the build output",
151151
Destination: &settings.Build.Quiet,
152152
},
153+
&cli.StringFlag{
154+
Name: "output",
155+
EnvVars: []string{"PLUGIN_OUTPUT"},
156+
Usage: "sets build output folder",
157+
Destination: &settings.Build.Output,
158+
},
153159
&cli.StringFlag{
154160
Name: "target",
155161
EnvVars: []string{"PLUGIN_TARGET"},

plugin/docker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
8484
}
8585

8686
args = append(args, build.Context)
87-
if !dryrun && len(build.Tags.Value()) > 0 {
87+
if !dryrun && build.Output == "" && len(build.Tags.Value()) > 0 {
8888
args = append(args, "--push")
8989
}
9090
if build.Compress {
@@ -114,6 +114,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
114114
if build.Quiet {
115115
args = append(args, "--quiet")
116116
}
117+
if build.Output != "" {
118+
args = append(args, "--output", build.Output)
119+
}
117120

118121
if len(build.Platforms.Value()) > 0 {
119122
args = append(args, "--platform", strings.Join(build.Platforms.Value()[:], ","))

plugin/impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type Build struct {
5959
NoCache bool // Docker build no-cache
6060
AddHost cli.StringSlice // Docker build add-host
6161
Quiet bool // Docker build quiet
62+
Output string // Docker build output folder
6263
}
6364

6465
// Settings for the Plugin.

0 commit comments

Comments
 (0)