Skip to content

Commit

Permalink
Add context input (#16)
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Sep 6, 2020
1 parent 54edbcd commit 1b18b10
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Inputs {
buildkitdFlags: string;
install: boolean;
use: boolean;
context: string;
}

export async function getInputs(): Promise<Inputs> {
Expand All @@ -21,7 +22,8 @@ export async function getInputs(): Promise<Inputs> {
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')
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ async function run(): Promise<void> {
if (inputs.use) {
createArgs.push('--use');
}
if (inputs.context) {
createArgs.push(inputs.context);
}
await exec.exec('docker', createArgs);

core.info('🏃 Booting builder...');
Expand Down

0 comments on commit 1b18b10

Please sign in to comment.