Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove aliases created by buildx when installing by default #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/main.ts
Expand Up @@ -70,6 +70,7 @@ async function run(): Promise<void> {
if (inputs.install) {
core.startGroup(`Setting buildx as default builder`);
await exec.exec('docker', ['buildx', 'install']);
stateHelper.setBuildxIsDefaultBuilder('true');
core.endGroup();
}

Expand Down Expand Up @@ -125,6 +126,20 @@ async function cleanup(): Promise<void> {
});
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();
}
}
Comment on lines +130 to 143
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #204 and #213 we should have this in the post hook and handled through cleanup input.


if (!stateHelper.IsPost) {
Expand Down
5 changes: 5 additions & 0 deletions src/state-helper.ts
@@ -1,5 +1,6 @@
import * as core from '@actions/core';

export const IsBuildxDefaultBuilder = !!process.env['STATE_isBuildxDefaultBuilder'];
export const IsPost = !!process.env['STATE_isPost'];
export const IsDebug = !!process.env['STATE_isDebug'];
export const builderName = process.env['STATE_builderName'] || '';
Expand All @@ -13,6 +14,10 @@ export function setBuilderName(builderName: string) {
core.saveState('builderName', builderName);
}

export function setBuildxIsDefaultBuilder(isBuildxDefaultBuilder: string) {
core.saveState('isBuildxDefaultBuilder', isBuildxDefaultBuilder);
}

export function setContainerName(containerName: string) {
core.saveState('containerName', containerName);
}
Expand Down