From 1b18b1078fb0c43533041fc2143e7b2f04c3c715 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 6 Sep 2020 16:37:52 +0200 Subject: [PATCH] Add context input (#16) Signed-off-by: CrazyMax --- README.md | 5 +++-- action.yml | 7 +++++-- dist/index.js | 6 +++++- src/context.ts | 4 +++- src/main.ts | 3 +++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3f7bb03..5b96039 100644 --- a/README.md +++ b/README.md @@ -128,12 +128,13 @@ Following inputs can be used as `step.with` keys | Name | Type | Description | |--------------------|---------|-----------------------------------| -| `version` | String | [Buildx](https://github.com/docker/buildx) version. (e.g. `v0.3.0`, `latest`) | +| `version` | String | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`) | | `driver` | String | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used (default `docker-container`) | -| `driver-opts` | CSV | List of additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options) | +| `driver-opts` | CSV | List of additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options) (eg. `image=moby/buildkit:master`) | | `buildkitd-flags` | String | [Flags for buildkitd](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md) daemon (since [buildx v0.3.0](https://github.com/docker/buildx/releases/tag/v0.3.0)) | | `install` | Bool | Sets up `docker build` command as an alias to `docker buildx` (default `false`) | | `use` | Bool | Switch to this builder instance (default `true`) | +| `context` | String | [Name of a context](https://github.com/docker/buildx#buildx-create-options-contextendpoint) from `docker context ls` or an endpoint as the address for docker socket (eg. `DOCKER_HOST` value) | > `CSV` type must be a newline-delimited string > ```yaml diff --git a/action.yml b/action.yml index c50254a..37f6a51 100644 --- a/action.yml +++ b/action.yml @@ -8,14 +8,14 @@ branding: inputs: version: - description: 'Buildx version. e.g. v0.3.0' + description: 'Buildx version. (eg. v0.3.0)' required: false driver: description: 'Sets the builder driver to be used' default: 'docker-container' required: false driver-opts: - description: 'List of additional driver-specific options. Eg. image=moby/buildkit:master' + description: 'List of additional driver-specific options. (eg. image=moby/buildkit:master)' required: false buildkitd-flags: description: 'Flags for buildkitd daemon' @@ -29,6 +29,9 @@ inputs: description: 'Switch to this builder instance' default: 'true' required: false + context: + description: 'Name of a context from docker context ls or an endpoint as the address for docker socket (eg. DOCKER_HOST value)' + required: false outputs: name: diff --git a/dist/index.js b/dist/index.js index 5c89cb5..86ade68 100644 --- a/dist/index.js +++ b/dist/index.js @@ -534,6 +534,9 @@ function run() { if (inputs.use) { createArgs.push('--use'); } + if (inputs.context) { + createArgs.push(inputs.context); + } yield exec.exec('docker', createArgs); core.info('🏃 Booting builder...'); yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); @@ -6553,7 +6556,8 @@ function getInputs() { buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host', install: /true/i.test(core.getInput('install')), - use: /true/i.test(core.getInput('use')) + use: /true/i.test(core.getInput('use')), + context: core.getInput('context') }; }); } diff --git a/src/context.ts b/src/context.ts index b8a3d9b..fa4d035 100644 --- a/src/context.ts +++ b/src/context.ts @@ -10,6 +10,7 @@ export interface Inputs { buildkitdFlags: string; install: boolean; use: boolean; + context: string; } export async function getInputs(): Promise { @@ -21,7 +22,8 @@ export async function getInputs(): Promise { core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host', install: /true/i.test(core.getInput('install')), - use: /true/i.test(core.getInput('use')) + use: /true/i.test(core.getInput('use')), + context: core.getInput('context') }; } diff --git a/src/main.ts b/src/main.ts index 608d0f9..3bbedf2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,9 @@ async function run(): Promise { if (inputs.use) { createArgs.push('--use'); } + if (inputs.context) { + createArgs.push(inputs.context); + } await exec.exec('docker', createArgs); core.info('🏃 Booting builder...');