mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-06-15 20:52:40 +08:00
check if driver compatible with keep-state
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4143b5899b
commit
36590ad0c1
33
README.md
33
README.md
@ -85,22 +85,23 @@ The following inputs can be used as `step.with` keys:
|
|||||||
> platforms: linux/amd64,linux/arm64
|
> platforms: linux/amd64,linux/arm64
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|------------------------------|----------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|------------------------------|----------|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `version` | String | | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
| `version` | String | | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
||||||
| `driver` | String | `docker-container` | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used |
|
| `name` | String | | Name of the builder. If not specified, one will be generated or if it already exists, it will be used instead of creating a new one |
|
||||||
| `driver-opts` | List | | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
| `driver` | String | `docker-container` | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used |
|
||||||
| `buildkitd-flags` | String | | [BuildKit daemon flags](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) |
|
| `driver-opts` | List | | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
||||||
| `buildkitd-config` \* | String | | [BuildKit daemon config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
| `buildkitd-flags` | String | | [BuildKit daemon flags](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) |
|
||||||
| `buildkitd-config-inline` \* | String | | Same as `buildkitd-config` but inline |
|
| `buildkitd-config` \* | String | | [BuildKit daemon config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
||||||
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
| `buildkitd-config-inline` \* | String | | Same as `buildkitd-config` but inline |
|
||||||
| `use` | Bool | `true` | Switch to this builder instance |
|
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
||||||
| `endpoint` | String | | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
| `use` | Bool | `true` | Switch to this builder instance |
|
||||||
| `platforms` | List/CSV | | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones. |
|
| `endpoint` | String | | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
||||||
| `append` | YAML | | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder |
|
| `platforms` | List/CSV | | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones |
|
||||||
| `cache-binary` | Bool | `true` | Cache buildx binary to GitHub Actions cache backend |
|
| `append` | YAML | | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder |
|
||||||
| `cleanup` | Bool | `true` | Cleanup temp files and remove builder at the end of a job |
|
| `keep-state` | Bool | `false` | Keep BuildKit state on `cleanup`. This is only useful on persistent self-hosted runners |
|
||||||
| `name` | String | Default Docker Context | Name of the builder to create or use. If a builder with this name already exists, it will be used instead of creating a new one. |
|
| `cache-binary` | Bool | `true` | Cache buildx binary to GitHub Actions cache backend |
|
||||||
|
| `cleanup` | Bool | `true` | Cleanup temp files and remove builder at the end of a job |
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> If you set the `buildkitd-flags` input, the default flags (`--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host`)
|
> If you set the `buildkitd-flags` input, the default flags (`--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host`)
|
||||||
|
13
action.yml
13
action.yml
@ -34,6 +34,9 @@ inputs:
|
|||||||
description: 'Switch to this builder instance'
|
description: 'Switch to this builder instance'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
name:
|
||||||
|
description: 'Name of the builder. If not specified, one will be generated or if it already exists, it will be used instead of creating a new one.'
|
||||||
|
required: false
|
||||||
endpoint:
|
endpoint:
|
||||||
description: 'Optional address for docker socket or context from `docker context ls`'
|
description: 'Optional address for docker socket or context from `docker context ls`'
|
||||||
required: false
|
required: false
|
||||||
@ -43,6 +46,10 @@ inputs:
|
|||||||
append:
|
append:
|
||||||
description: 'Append additional nodes to the builder'
|
description: 'Append additional nodes to the builder'
|
||||||
required: false
|
required: false
|
||||||
|
keep-state:
|
||||||
|
description: 'Keep BuildKit state on cleanup. This is only useful on persistent self-hosted runners.'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
cache-binary:
|
cache-binary:
|
||||||
description: 'Cache buildx binary to GitHub Actions cache backend'
|
description: 'Cache buildx binary to GitHub Actions cache backend'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
@ -50,12 +57,6 @@ inputs:
|
|||||||
cleanup:
|
cleanup:
|
||||||
description: 'Cleanup temp files and remove builder at the end of a job'
|
description: 'Cleanup temp files and remove builder at the end of a job'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
keep-state:
|
|
||||||
description: 'Keep BuildKit state on cleanup. This is only useful on persistent self-hosted runners.'
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
name:
|
|
||||||
description: 'Builder name set when creating the builder. If not specified, one will be generated.'
|
|
||||||
required: false
|
required: false
|
||||||
# TODO: remove deprecated config and config-inline inputs
|
# TODO: remove deprecated config and config-inline inputs
|
||||||
config:
|
config:
|
||||||
|
@ -42,17 +42,14 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'),
|
buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'),
|
||||||
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
|
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
|
||||||
append: core.getInput('append'),
|
append: core.getInput('append'),
|
||||||
|
keepState: core.getBooleanInput('keep-state'),
|
||||||
cacheBinary: core.getBooleanInput('cache-binary'),
|
cacheBinary: core.getBooleanInput('cache-binary'),
|
||||||
cleanup: core.getBooleanInput('cleanup'),
|
cleanup: core.getBooleanInput('cleanup')
|
||||||
keepState: core.getBooleanInput('keep-state')
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getBuilderName(name: string, driver: string): Promise<string> {
|
export async function getBuilderName(name: string, driver: string): Promise<string> {
|
||||||
if (driver == 'docker') {
|
return driver == 'docker' ? await Docker.context() : name || `builder-${crypto.randomUUID()}`;
|
||||||
return await Docker.context();
|
|
||||||
}
|
|
||||||
return name || `builder-${crypto.randomUUID()}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
|
@ -28,6 +28,12 @@ actionsToolkit.run(
|
|||||||
const standalone = await toolkit.buildx.isStandalone();
|
const standalone = await toolkit.buildx.isStandalone();
|
||||||
stateHelper.setStandalone(standalone);
|
stateHelper.setStandalone(standalone);
|
||||||
|
|
||||||
|
if (inputs.keepState && inputs.driver !== 'docker-container') {
|
||||||
|
// https://docs.docker.com/reference/cli/docker/buildx/rm/#keep-state
|
||||||
|
throw new Error(`Cannot use keep-state with ${inputs.driver} driver`);
|
||||||
|
}
|
||||||
|
stateHelper.setKeepState(inputs.keepState);
|
||||||
|
|
||||||
await core.group(`Docker info`, async () => {
|
await core.group(`Docker info`, async () => {
|
||||||
try {
|
try {
|
||||||
await Docker.printVersion();
|
await Docker.printVersion();
|
||||||
@ -115,7 +121,6 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateHelper.setKeepState(inputs.keepState);
|
|
||||||
|
|
||||||
if (inputs.driver !== 'docker') {
|
if (inputs.driver !== 'docker') {
|
||||||
await core.group(`Creating a new builder instance`, async () => {
|
await core.group(`Creating a new builder instance`, async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user