Compare commits

..

4 Commits

Author SHA1 Message Date
Daniel Amar
7cd46c6dac
Merge 66d7daabf8 into 3f1544eb9e 2025-05-21 12:07:12 +02:00
CrazyMax
3f1544eb9e
Merge pull request #139 from hashhar/hashhar/cleanup-aliases
Some checks failed
ci / debug (push) Failing after 1m18s
ci / install (push) Failing after 1s
ci / use (false) (push) Failing after 2s
ci / use (true) (push) Failing after 1s
ci / driver (image=moby/buildkit:latest) (push) Failing after 2s
ci / driver (image=moby/buildkit:master network=host ) (push) Failing after 3s
ci / docker-driver (push) Failing after 1s
ci / endpoint (push) Failing after 1s
ci / config (push) Failing after 2s
ci / config-inline (push) Failing after 3s
ci / with-qemu (, all) (push) Failing after 2s
ci / with-qemu (, arm64,riscv64,arm) (push) Failing after 2s
ci / with-qemu (v0.9.1, all) (push) Failing after 2s
ci / with-qemu (v0.9.1, arm64,riscv64,arm) (push) Failing after 2s
ci / build-ref (cb185f095fd3d9444e0aa605d3789e9e05f2a1e7) (push) Failing after 1m17s
ci / build-ref (master) (push) Failing after 2s
ci / build-ref (refs/pull/731/head) (push) Failing after 2s
ci / build-ref (refs/tags/v0.5.1) (push) Failing after 2s
ci / standalone-cmd (push) Failing after 1s
ci / standalone-action (push) Failing after 3s
ci / standalone-install-error (push) Failing after 2s
ci / append (push) Failing after 2s
ci / platforms (push) Failing after 3s
ci / docker-context (push) Failing after 1s
ci / cleanup (false) (push) Failing after 1s
ci / cleanup (true) (push) Failing after 2s
ci / k3s (v0.10.5) (push) Failing after 6s
ci / k3s (v0.11.0) (push) Failing after 3s
ci / cache-binary (false) (push) Failing after 2s
ci / cache-binary (true) (push) Failing after 1s
Remove aliases created by buildx when installing by default
2025-05-21 12:04:20 +02:00
CrazyMax
f3204bbfac
chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-21 12:01:07 +02:00
Ashhar Hasan
4ba329ef89
Remove aliases created by buildx when installing by default
If the action is configured to install buildx by default using the
input then docker buildx sets up docker build as an alias for buildx
making all docker build calls use the buildx builder instead of
traditional builders. The action didn't perform cleanup in this case to
uninstall the aliases which meant that any future workflows running on
same GitHub Actions runner would get the buildx builders even if it did
not explicitly request it.

This commit tracks if the aliases were installed and removes them during
post step of the action if so.

Signed-off-by: Ashhar Hasan <hashhar_dev@outlook.com>
2025-05-21 11:59:28 +02:00
4 changed files with 29 additions and 11 deletions

20
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -251,6 +251,7 @@ actionsToolkit.run(
throw new Error(`Cannot set buildx as default builder without the Docker CLI`);
}
await core.group(`Setting buildx as default builder`, async () => {
stateHelper.setBuildxIsDefaultBuilder(true);
const installCmd = await toolkit.buildx.getCommand(['install']);
await Exec.getExecOutput(installCmd.command, installCmd.args, {
ignoreReturnCode: true
@ -351,5 +352,17 @@ actionsToolkit.run(
fs.rmSync(stateHelper.certsDir, {recursive: true});
});
}
if (stateHelper.buildxIsDefaultBuilder) {
await core.group(`Restoring default builder`, async () => {
await Exec.getExecOutput('docker', ['buildx', 'uninstall'], {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
core.warning(`${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
}
});
});
}
}
);

View File

@ -8,6 +8,7 @@ export const containerName = process.env['STATE_containerName'] || '';
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 function setDebug(debug: string) {
core.saveState('isDebug', debug);
@ -40,3 +41,7 @@ export function setTmpDockerContext(tmpDockerContext: string) {
export function setCleanup(cleanup: boolean) {
core.saveState('cleanup', cleanup);
}
export function setBuildxIsDefaultBuilder(buildxIsDefaultBuilder: boolean) {
core.saveState('buildxIsDefaultBuilder', buildxIsDefaultBuilder);
}