1
0
Fork 0
mirror of https://github.com/docker/setup-buildx-action.git synced 2025-06-07 14:11:49 +02:00

cleanup input to remove builder and temp files

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-03-03 11:56:21 +01:00
parent 03a7a3d9fb
commit 8b13d483f2
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
7 changed files with 84 additions and 24 deletions

View file

@ -20,6 +20,7 @@ export interface Inputs {
config: string;
configInline: string;
append: string;
cleanup: boolean;
}
export async function getInputs(): Promise<Inputs> {
@ -35,7 +36,8 @@ export async function getInputs(): Promise<Inputs> {
endpoint: core.getInput('endpoint'),
config: core.getInput('config'),
configInline: core.getInput('config-inline'),
append: core.getInput('append')
append: core.getInput('append'),
cleanup: core.getBooleanInput('cleanup')
};
}

View file

@ -16,8 +16,9 @@ actionsToolkit.run(
// main
async () => {
const inputs: context.Inputs = await context.getInputs();
const toolkit = new Toolkit();
stateHelper.setCleanup(inputs.cleanup);
const toolkit = new Toolkit();
const standalone = await toolkit.buildx.isStandalone();
stateHelper.setStandalone(standalone);
@ -164,9 +165,13 @@ actionsToolkit.run(
});
}
if (!stateHelper.cleanup) {
return;
}
if (stateHelper.builderName.length > 0) {
await core.group(`Removing builder`, async () => {
const buildx = new Buildx({standalone: /true/i.test(stateHelper.standalone)});
const buildx = new Buildx({standalone: stateHelper.standalone});
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
await exec
.getExecOutput(rmCmd.command, rmCmd.args, {

View file

@ -1,10 +1,11 @@
import * as core from '@actions/core';
export const IsDebug = !!process.env['STATE_isDebug'];
export const standalone = process.env['STATE_standalone'] || '';
export const standalone = /true/i.test(process.env['STATE_standalone'] || '');
export const builderName = process.env['STATE_builderName'] || '';
export const containerName = process.env['STATE_containerName'] || '';
export const certsDir = process.env['STATE_certsDir'] || '';
export const cleanup = /true/i.test(process.env['STATE_cleanup'] || '');
export function setDebug(debug: string) {
core.saveState('isDebug', debug);
@ -25,3 +26,7 @@ export function setContainerName(containerName: string) {
export function setCertsDir(certsDir: string) {
core.saveState('certsDir', certsDir);
}
export function setCleanup(cleanup: boolean) {
core.saveState('cleanup', cleanup);
}