mirror of
https://gitea.com/docker/setup-buildx-action.git
synced 2024-11-22 01:19:35 +01:00
Merge pull request #218 from crazy-max/fix-builder-removal
do not remove builder using the docker driver
This commit is contained in:
commit
eb27bcbef3
4 changed files with 25 additions and 13 deletions
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
29
src/main.ts
29
src/main.ts
|
@ -4,6 +4,7 @@ import * as core from '@actions/core';
|
|||
import * as exec from '@actions/exec';
|
||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||
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 {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||
|
@ -60,6 +61,7 @@ actionsToolkit.run(
|
|||
|
||||
core.setOutput('name', inputs.name);
|
||||
stateHelper.setBuilderName(inputs.name);
|
||||
stateHelper.setBuilderDriver(inputs.driver);
|
||||
|
||||
fs.mkdirSync(Buildx.certsDir, {recursive: true});
|
||||
stateHelper.setCertsDir(Buildx.certsDir);
|
||||
|
@ -169,19 +171,24 @@ actionsToolkit.run(
|
|||
return;
|
||||
}
|
||||
|
||||
if (stateHelper.builderName.length > 0) {
|
||||
if (stateHelper.builderDriver != 'docker' && stateHelper.builderName.length > 0) {
|
||||
await core.group(`Removing builder`, async () => {
|
||||
const buildx = new Buildx({standalone: stateHelper.standalone});
|
||||
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
||||
await exec
|
||||
.getExecOutput(rmCmd.command, rmCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
})
|
||||
.then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
core.warning(res.stderr.trim());
|
||||
}
|
||||
});
|
||||
const builder = new Builder({buildx: buildx});
|
||||
if (await builder.exists(stateHelper.builderName)) {
|
||||
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
||||
await exec
|
||||
.getExecOutput(rmCmd.command, rmCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
})
|
||||
.then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
core.warning(res.stderr.trim());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
core.info(`${stateHelper.builderName} does not exist`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import * as core from '@actions/core';
|
|||
export const IsDebug = !!process.env['STATE_isDebug'];
|
||||
export const standalone = /true/i.test(process.env['STATE_standalone'] || '');
|
||||
export const builderName = process.env['STATE_builderName'] || '';
|
||||
export const builderDriver = process.env['STATE_builderDriver'] || '';
|
||||
export const containerName = process.env['STATE_containerName'] || '';
|
||||
export const certsDir = process.env['STATE_certsDir'] || '';
|
||||
export const cleanup = /true/i.test(process.env['STATE_cleanup'] || '');
|
||||
|
@ -19,6 +20,10 @@ export function setBuilderName(builderName: string) {
|
|||
core.saveState('builderName', builderName);
|
||||
}
|
||||
|
||||
export function setBuilderDriver(builderDriver: string) {
|
||||
core.saveState('builderDriver', builderDriver);
|
||||
}
|
||||
|
||||
export function setContainerName(containerName: string) {
|
||||
core.saveState('containerName', containerName);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue