mirror of
https://github.com/docker/setup-buildx-action.git
synced 2024-11-26 15:59:03 +00:00
rename and align config inputs
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b7cf918227
commit
f876da6242
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -251,7 +251,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
config: /tmp/buildkitd.toml
|
buildkitd-config: /tmp/buildkitd.toml
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
@ -275,7 +275,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
config-inline: |
|
buildkitd-config-inline: |
|
||||||
debug = true
|
debug = true
|
||||||
[registry."docker.io"]
|
[registry."docker.io"]
|
||||||
mirrors = ["mirror.gcr.io"]
|
mirrors = ["mirror.gcr.io"]
|
||||||
@ -564,7 +564,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|
||||||
cacheBinary:
|
cache-binary:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
32
README.md
32
README.md
@ -85,23 +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 |
|
| `driver` | String | `docker-container` | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used |
|
||||||
| `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-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-flags` | String | | [Flags for buildkitd](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) daemon |
|
| `buildkitd-flags` | String | | [BuildKit daemon flags](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) |
|
||||||
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
| `buildkitd-config` \* | String | | [BuildKit daemon config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
||||||
| `use` | Bool | `true` | Switch to this builder instance |
|
| `buildkitd-config-inline` \* | String | | Same as `buildkitd-config` but inline |
|
||||||
| `endpoint` | String | | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
||||||
| `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. |
|
| `use` | Bool | `true` | Switch to this builder instance |
|
||||||
| `config`¹ | String | | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
| `endpoint` | String | | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
||||||
| `config-inline`¹ | String | | Same as `config` but inline |
|
| `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. |
|
||||||
| `append` | YAML | | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder |
|
| `append` | YAML | | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder |
|
||||||
| `cache-binary` | Bool | `true` | Cache buildx binary to GitHub Actions cache backend |
|
| `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 |
|
| `cleanup` | Bool | `true` | Cleanup temp files and remove builder at the end of a job |
|
||||||
|
|
||||||
> * ¹ `config` and `config-inline` are mutually exclusive
|
_\* `buildkitd-config` and `buildkitd-config-inline` are mutually exclusive_
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
|
@ -1,12 +1,31 @@
|
|||||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
|
|
||||||
|
const fixturesDir = path.join(__dirname, 'fixtures');
|
||||||
|
// prettier-ignore
|
||||||
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'setup-buildx-jest');
|
||||||
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
|
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||||
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
|
}
|
||||||
|
return tmpDir;
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
|
return tmpName;
|
||||||
|
});
|
||||||
|
|
||||||
jest.mock('uuid');
|
jest.mock('uuid');
|
||||||
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
|
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
|
||||||
|
|
||||||
@ -171,6 +190,42 @@ describe('getCreateArgs', () => {
|
|||||||
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
'--driver', 'unknown',
|
'--driver', 'unknown',
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['buildkitd-config', path.join(fixturesDir, 'buildkitd.toml')],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'docker-container',
|
||||||
|
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
'--config', tmpName,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
9,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['buildkitd-config-inline', 'debug = true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'docker-container',
|
||||||
|
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
'--config', tmpName,
|
||||||
|
]
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
'[%d] given buildx %s and %p as inputs, returns %p',
|
'[%d] given buildx %s and %p as inputs, returns %p',
|
||||||
|
1
__tests__/fixtures/buildkitd.toml
Normal file
1
__tests__/fixtures/buildkitd.toml
Normal file
@ -0,0 +1 @@
|
|||||||
|
debug = true
|
23
action.yml
23
action.yml
@ -18,9 +18,15 @@ inputs:
|
|||||||
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
|
required: false
|
||||||
buildkitd-flags:
|
buildkitd-flags:
|
||||||
description: 'Flags for buildkitd daemon'
|
description: 'BuildKit daemon flags'
|
||||||
default: '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
|
default: '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
|
||||||
required: false
|
required: false
|
||||||
|
buildkitd-config:
|
||||||
|
description: 'BuildKit daemon config file'
|
||||||
|
required: false
|
||||||
|
buildkitd-config-inline:
|
||||||
|
description: 'Inline BuildKit daemon config'
|
||||||
|
required: false
|
||||||
install:
|
install:
|
||||||
description: 'Sets up docker build command as an alias to docker buildx build'
|
description: 'Sets up docker build command as an alias to docker buildx build'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
@ -35,12 +41,6 @@ inputs:
|
|||||||
platforms:
|
platforms:
|
||||||
description: 'Fixed platforms for current node. If not empty, values take priority over the detected ones'
|
description: 'Fixed platforms for current node. If not empty, values take priority over the detected ones'
|
||||||
required: false
|
required: false
|
||||||
config:
|
|
||||||
description: 'BuildKit config file'
|
|
||||||
required: false
|
|
||||||
config-inline:
|
|
||||||
description: 'Inline BuildKit config'
|
|
||||||
required: false
|
|
||||||
append:
|
append:
|
||||||
description: 'Append additional nodes to the builder'
|
description: 'Append additional nodes to the builder'
|
||||||
required: false
|
required: false
|
||||||
@ -52,6 +52,15 @@ inputs:
|
|||||||
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'
|
||||||
required: false
|
required: false
|
||||||
|
# deprecated inputs
|
||||||
|
config:
|
||||||
|
description: 'BuildKit daemon config file'
|
||||||
|
deprecationMessage: 'Use buildkitd-config instead'
|
||||||
|
required: false
|
||||||
|
config-inline:
|
||||||
|
description: 'Inline BuildKit daemon config'
|
||||||
|
deprecationMessage: 'Use buildkitd-config-inline instead'
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
name:
|
name:
|
||||||
|
@ -13,12 +13,12 @@ export interface Inputs {
|
|||||||
driver: string;
|
driver: string;
|
||||||
driverOpts: string[];
|
driverOpts: string[];
|
||||||
buildkitdFlags: string;
|
buildkitdFlags: string;
|
||||||
|
buildkitdConfig: string;
|
||||||
|
buildkitdConfigInline: string;
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
install: boolean;
|
install: boolean;
|
||||||
use: boolean;
|
use: boolean;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
config: string;
|
|
||||||
configInline: string;
|
|
||||||
append: string;
|
append: string;
|
||||||
cacheBinary: boolean;
|
cacheBinary: boolean;
|
||||||
cleanup: boolean;
|
cleanup: boolean;
|
||||||
@ -35,8 +35,8 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
install: core.getBooleanInput('install'),
|
install: core.getBooleanInput('install'),
|
||||||
use: core.getBooleanInput('use'),
|
use: core.getBooleanInput('use'),
|
||||||
endpoint: core.getInput('endpoint'),
|
endpoint: core.getInput('endpoint'),
|
||||||
config: core.getInput('config'),
|
buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'),
|
||||||
configInline: core.getInput('config-inline'),
|
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
|
||||||
append: core.getInput('append'),
|
append: core.getInput('append'),
|
||||||
cacheBinary: core.getBooleanInput('cache-binary'),
|
cacheBinary: core.getBooleanInput('cache-binary'),
|
||||||
cleanup: core.getBooleanInput('cleanup')
|
cleanup: core.getBooleanInput('cleanup')
|
||||||
@ -64,10 +64,10 @@ export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<A
|
|||||||
args.push('--use');
|
args.push('--use');
|
||||||
}
|
}
|
||||||
if (driverSupportsFlags(inputs.driver)) {
|
if (driverSupportsFlags(inputs.driver)) {
|
||||||
if (inputs.config) {
|
if (inputs.buildkitdConfig) {
|
||||||
args.push('--config', toolkit.buildkit.config.resolveFromFile(inputs.config));
|
args.push('--config', toolkit.buildkit.config.resolveFromFile(inputs.buildkitdConfig));
|
||||||
} else if (inputs.configInline) {
|
} else if (inputs.buildkitdConfigInline) {
|
||||||
args.push('--config', toolkit.buildkit.config.resolveFromString(inputs.configInline));
|
args.push('--config', toolkit.buildkit.config.resolveFromString(inputs.buildkitdConfigInline));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputs.endpoint) {
|
if (inputs.endpoint) {
|
||||||
|
Loading…
Reference in New Issue
Block a user