mirror of
https://gitea.com/docker/setup-buildx-action.git
synced 2024-11-22 01:19:35 +01:00
cache-binary input to enable/disable caching binary to GHA cache backend
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
524315340d
commit
a4180f835d
6 changed files with 37 additions and 2 deletions
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
|
@ -563,3 +563,22 @@ jobs:
|
||||||
uses: docker/build-push-action@master
|
uses: docker/build-push-action@master
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|
||||||
|
cacheBinary:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
cache:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: v0.11.2
|
||||||
|
cache-binary: ${{ matrix.cache }}
|
||||||
|
|
|
@ -98,6 +98,7 @@ The following inputs can be used as `step.with` keys:
|
||||||
| `config`¹ | String | | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
| `config`¹ | String | | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
||||||
| `config-inline`¹ | String | | Same as `config` but inline |
|
| `config-inline`¹ | String | | Same as `config` but inline |
|
||||||
| `append` | YAML | | [Append additional nodes](docs/advanced/append-nodes.md) to the builder |
|
| `append` | YAML | | [Append additional nodes](docs/advanced/append-nodes.md) to the builder |
|
||||||
|
| `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
|
> * ¹ `config` and `config-inline` are mutually exclusive
|
||||||
|
|
|
@ -32,6 +32,7 @@ describe('getCreateArgs', () => {
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -49,6 +50,7 @@ describe('getCreateArgs', () => {
|
||||||
['driver', 'docker'],
|
['driver', 'docker'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -66,6 +68,7 @@ describe('getCreateArgs', () => {
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver-opts', 'image=moby/buildkit:master\nnetwork=host'],
|
['driver-opts', 'image=moby/buildkit:master\nnetwork=host'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -85,6 +88,7 @@ describe('getCreateArgs', () => {
|
||||||
['endpoint', 'tls://foo:1234'],
|
['endpoint', 'tls://foo:1234'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -104,6 +108,7 @@ describe('getCreateArgs', () => {
|
||||||
['endpoint', 'tls://foo:1234'],
|
['endpoint', 'tls://foo:1234'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -122,6 +127,7 @@ describe('getCreateArgs', () => {
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`],
|
['driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -139,6 +145,7 @@ describe('getCreateArgs', () => {
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"'],
|
['platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -156,6 +163,7 @@ describe('getCreateArgs', () => {
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver', 'unknown'],
|
['driver', 'unknown'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
|
@ -199,6 +207,7 @@ describe('getAppendArgs', () => {
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
['cleanup', 'true'],
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,10 @@ inputs:
|
||||||
append:
|
append:
|
||||||
description: 'Append additional nodes to the builder'
|
description: 'Append additional nodes to the builder'
|
||||||
required: false
|
required: false
|
||||||
|
cache-binary:
|
||||||
|
description: 'Cache buildx binary to GitHub Actions cache backend'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
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'
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface Inputs {
|
||||||
config: string;
|
config: string;
|
||||||
configInline: string;
|
configInline: string;
|
||||||
append: string;
|
append: string;
|
||||||
|
cacheBinary: boolean;
|
||||||
cleanup: boolean;
|
cleanup: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ export async function getInputs(): Promise<Inputs> {
|
||||||
config: core.getInput('config'),
|
config: core.getInput('config'),
|
||||||
configInline: core.getInput('config-inline'),
|
configInline: core.getInput('config-inline'),
|
||||||
append: core.getInput('append'),
|
append: core.getInput('append'),
|
||||||
|
cacheBinary: core.getBooleanInput('cache-binary'),
|
||||||
cleanup: core.getBooleanInput('cleanup')
|
cleanup: core.getBooleanInput('cleanup')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,11 @@ actionsToolkit.run(
|
||||||
throw new Error(`Cannot build from source without the Docker CLI`);
|
throw new Error(`Cannot build from source without the Docker CLI`);
|
||||||
}
|
}
|
||||||
await core.group(`Build buildx from source`, async () => {
|
await core.group(`Build buildx from source`, async () => {
|
||||||
toolPath = await toolkit.buildxInstall.build(inputs.version);
|
toolPath = await toolkit.buildxInstall.build(inputs.version, !inputs.cacheBinary);
|
||||||
});
|
});
|
||||||
} else if (!(await toolkit.buildx.isAvailable()) || inputs.version) {
|
} else if (!(await toolkit.buildx.isAvailable()) || inputs.version) {
|
||||||
await core.group(`Download buildx from GitHub Releases`, async () => {
|
await core.group(`Download buildx from GitHub Releases`, async () => {
|
||||||
toolPath = await toolkit.buildxInstall.download(inputs.version || 'latest');
|
toolPath = await toolkit.buildxInstall.download(inputs.version || 'latest', !inputs.cacheBinary);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
|
|
Loading…
Reference in a new issue