mirror of
https://github.com/docker/setup-buildx-action.git
synced 2024-11-27 00:09:02 +00:00
check builder exists before removal
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
85ce96bcbc
commit
e2df91e851
26
src/main.ts
26
src/main.ts
@ -4,6 +4,7 @@ import * as core from '@actions/core';
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
|
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
|
||||||
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 {Util} from '@docker/actions-toolkit/lib/util';
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
@ -173,16 +174,21 @@ actionsToolkit.run(
|
|||||||
if (stateHelper.builderDriver != 'docker' && stateHelper.builderName.length > 0) {
|
if (stateHelper.builderDriver != 'docker' && stateHelper.builderName.length > 0) {
|
||||||
await core.group(`Removing builder`, async () => {
|
await core.group(`Removing builder`, async () => {
|
||||||
const buildx = new Buildx({standalone: stateHelper.standalone});
|
const buildx = new Buildx({standalone: stateHelper.standalone});
|
||||||
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
const builder = new Builder({buildx: buildx});
|
||||||
await exec
|
if (await builder.exists(stateHelper.builderName)) {
|
||||||
.getExecOutput(rmCmd.command, rmCmd.args, {
|
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
||||||
ignoreReturnCode: true
|
await exec
|
||||||
})
|
.getExecOutput(rmCmd.command, rmCmd.args, {
|
||||||
.then(res => {
|
ignoreReturnCode: true
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
})
|
||||||
core.warning(res.stderr.trim());
|
.then(res => {
|
||||||
}
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
});
|
core.warning(res.stderr.trim());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
core.info(`${stateHelper.builderName} does not exist`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user