mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-06-30 04:44:15 +00:00
Support to retain cache
Signed-off-by: Balaji Arun <balajia@vt.edu>
This commit is contained in:
parent
3f1544eb9e
commit
4143b5899b
6 changed files with 88 additions and 11 deletions
|
@ -25,12 +25,13 @@ export interface Inputs {
|
|||
append: string;
|
||||
cacheBinary: boolean;
|
||||
cleanup: boolean;
|
||||
keepState: boolean;
|
||||
}
|
||||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
return {
|
||||
version: core.getInput('version'),
|
||||
name: await getBuilderName(core.getInput('driver') || 'docker-container'),
|
||||
name: await getBuilderName(core.getInput('name'), core.getInput('driver') || 'docker-container'),
|
||||
driver: core.getInput('driver') || 'docker-container',
|
||||
driverOpts: Util.getInputList('driver-opts', {ignoreComma: true, quote: false}),
|
||||
buildkitdFlags: core.getInput('buildkitd-flags'),
|
||||
|
@ -42,12 +43,16 @@ export async function getInputs(): Promise<Inputs> {
|
|||
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
|
||||
append: core.getInput('append'),
|
||||
cacheBinary: core.getBooleanInput('cache-binary'),
|
||||
cleanup: core.getBooleanInput('cleanup')
|
||||
cleanup: core.getBooleanInput('cleanup'),
|
||||
keepState: core.getBooleanInput('keep-state')
|
||||
};
|
||||
}
|
||||
|
||||
export async function getBuilderName(driver: string): Promise<string> {
|
||||
return driver == 'docker' ? await Docker.context() : `builder-${crypto.randomUUID()}`;
|
||||
export async function getBuilderName(name: string, driver: string): Promise<string> {
|
||||
if (driver == 'docker') {
|
||||
return await Docker.context();
|
||||
}
|
||||
return name || `builder-${crypto.randomUUID()}`;
|
||||
}
|
||||
|
||||
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||
|
|
|
@ -115,6 +115,7 @@ actionsToolkit.run(
|
|||
});
|
||||
}
|
||||
}
|
||||
stateHelper.setKeepState(inputs.keepState);
|
||||
|
||||
if (inputs.driver !== 'docker') {
|
||||
await core.group(`Creating a new builder instance`, async () => {
|
||||
|
@ -249,7 +250,7 @@ actionsToolkit.run(
|
|||
const buildx = new Buildx({standalone: stateHelper.standalone});
|
||||
const builder = new Builder({buildx: buildx});
|
||||
if (await builder.exists(stateHelper.builderName)) {
|
||||
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
||||
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName, ...(stateHelper.keepState ? ['--keep-state'] : [])]);
|
||||
await Exec.getExecOutput(rmCmd.command, rmCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
}).then(res => {
|
||||
|
|
|
@ -9,6 +9,7 @@ export const certsDir = process.env['STATE_certsDir'] || '';
|
|||
export const tmpDockerContext = process.env['STATE_tmpDockerContext'] || '';
|
||||
export const cleanup = /true/i.test(process.env['STATE_cleanup'] || '');
|
||||
export const buildxIsDefaultBuilder = /true/i.test(process.env['STATE_buildxIsDefaultBuilder'] || '');
|
||||
export const keepState = !!process.env['STATE_keepState'];
|
||||
|
||||
export function setDebug(debug: string) {
|
||||
core.saveState('isDebug', debug);
|
||||
|
@ -45,3 +46,7 @@ export function setCleanup(cleanup: boolean) {
|
|||
export function setBuildxIsDefaultBuilder(buildxIsDefaultBuilder: boolean) {
|
||||
core.saveState('buildxIsDefaultBuilder', buildxIsDefaultBuilder);
|
||||
}
|
||||
|
||||
export function setKeepState(retain: boolean) {
|
||||
core.saveState('keepState', retain);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue