mirror of
https://github.com/docker/setup-buildx-action.git
synced 2024-11-15 21:53:51 +08:00
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>
This commit is contained in:
parent
74283caced
commit
fdd372a0be
4
dist/index.js
generated
vendored
4
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
15
src/main.ts
15
src/main.ts
@ -70,6 +70,7 @@ async function run(): Promise<void> {
|
|||||||
if (inputs.install) {
|
if (inputs.install) {
|
||||||
core.startGroup(`Setting buildx as default builder`);
|
core.startGroup(`Setting buildx as default builder`);
|
||||||
await exec.exec('docker', ['buildx', 'install']);
|
await exec.exec('docker', ['buildx', 'install']);
|
||||||
|
stateHelper.setBuildxIsDefaultBuilder('true');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +126,20 @@ async function cleanup(): Promise<void> {
|
|||||||
});
|
});
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateHelper.IsBuildxDefaultBuilder) {
|
||||||
|
core.startGroup('Uninstalling build aliased to buildx');
|
||||||
|
await exec
|
||||||
|
.getExecOutput('docker', ['buildx', 'uninstall'], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
core.warning(res.stderr.trim());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateHelper.IsPost) {
|
if (!stateHelper.IsPost) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
export const IsBuildxDefaultBuilder = !!process.env['STATE_isBuildxDefaultBuilder'];
|
||||||
export const IsPost = !!process.env['STATE_isPost'];
|
export const IsPost = !!process.env['STATE_isPost'];
|
||||||
export const IsDebug = !!process.env['STATE_isDebug'];
|
export const IsDebug = !!process.env['STATE_isDebug'];
|
||||||
export const builderName = process.env['STATE_builderName'] || '';
|
export const builderName = process.env['STATE_builderName'] || '';
|
||||||
@ -13,6 +14,10 @@ export function setBuilderName(builderName: string) {
|
|||||||
core.saveState('builderName', builderName);
|
core.saveState('builderName', builderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setBuildxIsDefaultBuilder(isBuildxDefaultBuilder: string) {
|
||||||
|
core.saveState('isBuildxDefaultBuilder', isBuildxDefaultBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
export function setContainerName(containerName: string) {
|
export function setContainerName(containerName: string) {
|
||||||
core.saveState('containerName', containerName);
|
core.saveState('containerName', containerName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user