mirror of
https://github.com/docker/build-push-action.git
synced 2025-08-10 02:22:11 +00:00
Merge pull request #116 from useblacksmith/bump-buildkitd
*: allow users to pass in a buildx version
This commit is contained in:
commit
68105fca60
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -59,6 +59,7 @@ export interface Inputs {
|
|||||||
'github-token': string;
|
'github-token': string;
|
||||||
nofallback: boolean;
|
nofallback: boolean;
|
||||||
setupOnly: boolean;
|
setupOnly: boolean;
|
||||||
|
'buildx-version': string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputs(): Promise<Inputs> {
|
export async function getInputs(): Promise<Inputs> {
|
||||||
@ -98,6 +99,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
'github-token': core.getInput('github-token'),
|
'github-token': core.getInput('github-token'),
|
||||||
nofallback: core.getBooleanInput('nofallback'),
|
nofallback: core.getBooleanInput('nofallback'),
|
||||||
setupOnly: core.getBooleanInput('setup-only'),
|
setupOnly: core.getBooleanInput('setup-only'),
|
||||||
|
'buildx-version': core.getInput('buildx-version')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/main.ts
20
src/main.ts
@ -23,7 +23,8 @@ import * as reporter from './reporter';
|
|||||||
import {setupStickyDisk, startAndConfigureBuildkitd, getNumCPUs, leaveTailnet, pruneBuildkitCache} from './setup_builder';
|
import {setupStickyDisk, startAndConfigureBuildkitd, getNumCPUs, leaveTailnet, pruneBuildkitCache} from './setup_builder';
|
||||||
import {Metric_MetricType} from '@buf/blacksmith_vm-agent.bufbuild_es/stickydisk/v1/stickydisk_pb';
|
import {Metric_MetricType} from '@buf/blacksmith_vm-agent.bufbuild_es/stickydisk/v1/stickydisk_pb';
|
||||||
|
|
||||||
const buildxVersion = 'v0.17.0';
|
const DEFAULT_BUILDX_VERSION = 'v0.23.0';
|
||||||
|
|
||||||
const mountPoint = '/var/lib/buildkit';
|
const mountPoint = '/var/lib/buildkit';
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
@ -73,6 +74,12 @@ async function setupBuildx(version: string, toolkit: Toolkit): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validates the version string to ensure it matches a basic expected pattern.
|
||||||
|
// Accepts versions of the form `v<MAJOR>.<MINOR>.<PATCH>` (e.g., v0.20.0) or the literal string `latest`.
|
||||||
|
function isValidBuildxVersion(version: string): boolean {
|
||||||
|
return version === 'latest' || /^v\d+\.\d+\.\d+$/.test(version);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to set up a Blacksmith builder for Docker builds.
|
* Attempts to set up a Blacksmith builder for Docker builds.
|
||||||
*
|
*
|
||||||
@ -159,6 +166,17 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Determine which Buildx version to install. If the user provided an input, validate it;
|
||||||
|
// otherwise, fall back to the default.
|
||||||
|
let buildxVersion = DEFAULT_BUILDX_VERSION;
|
||||||
|
if (inputs['buildx-version'] && inputs['buildx-version'].trim() !== '') {
|
||||||
|
if (isValidBuildxVersion(inputs['buildx-version'])) {
|
||||||
|
buildxVersion = inputs['buildx-version'];
|
||||||
|
} else {
|
||||||
|
core.warning(`Invalid buildx-version '${inputs['buildx-version']}'. ` + `Expected 'latest' or a version in the form v<MAJOR>.<MINOR>.<PATCH>. ` + `Falling back to default ${DEFAULT_BUILDX_VERSION}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await core.group(`Setup buildx`, async () => {
|
await core.group(`Setup buildx`, async () => {
|
||||||
await setupBuildx(buildxVersion, toolkit);
|
await setupBuildx(buildxVersion, toolkit);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user