Skip to content

Commit 3f1544e

Browse files
authored
Merge pull request #139 from hashhar/hashhar/cleanup-aliases
Remove aliases created by buildx when installing by default
2 parents e600775 + f3204bb commit 3f1544e

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

dist/index.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ actionsToolkit.run(
179179
throw new Error(`Cannot set buildx as default builder without the Docker CLI`);
180180
}
181181
await core.group(`Setting buildx as default builder`, async () => {
182+
stateHelper.setBuildxIsDefaultBuilder(true);
182183
const installCmd = await toolkit.buildx.getCommand(['install']);
183184
await Exec.getExecOutput(installCmd.command, installCmd.args, {
184185
ignoreReturnCode: true
@@ -279,5 +280,17 @@ actionsToolkit.run(
279280
fs.rmSync(stateHelper.certsDir, {recursive: true});
280281
});
281282
}
283+
284+
if (stateHelper.buildxIsDefaultBuilder) {
285+
await core.group(`Restoring default builder`, async () => {
286+
await Exec.getExecOutput('docker', ['buildx', 'uninstall'], {
287+
ignoreReturnCode: true
288+
}).then(res => {
289+
if (res.stderr.length > 0 && res.exitCode != 0) {
290+
core.warning(`${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
291+
}
292+
});
293+
});
294+
}
282295
}
283296
);

src/state-helper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const containerName = process.env['STATE_containerName'] || '';
88
export const certsDir = process.env['STATE_certsDir'] || '';
99
export const tmpDockerContext = process.env['STATE_tmpDockerContext'] || '';
1010
export const cleanup = /true/i.test(process.env['STATE_cleanup'] || '');
11+
export const buildxIsDefaultBuilder = /true/i.test(process.env['STATE_buildxIsDefaultBuilder'] || '');
1112

1213
export function setDebug(debug: string) {
1314
core.saveState('isDebug', debug);
@@ -40,3 +41,7 @@ export function setTmpDockerContext(tmpDockerContext: string) {
4041
export function setCleanup(cleanup: boolean) {
4142
core.saveState('cleanup', cleanup);
4243
}
44+
45+
export function setBuildxIsDefaultBuilder(buildxIsDefaultBuilder: boolean) {
46+
core.saveState('buildxIsDefaultBuilder', buildxIsDefaultBuilder);
47+
}

0 commit comments

Comments
 (0)