mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-23 08:26:38 +02:00
Improve builder name generation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
5c0276ad2c
commit
db0ae322da
6 changed files with 741 additions and 118 deletions
|
@ -34,15 +34,6 @@ export async function isAvailable(): Promise<Boolean> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function countBuilders(): Promise<number> {
|
||||
return await exec.exec(`docker`, ['buildx', 'ls'], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(`Cannot list builders: ${res.stderr}`);
|
||||
}
|
||||
return (res.stdout.trim().split(`\n`).length - 1) / 2;
|
||||
});
|
||||
}
|
||||
|
||||
export async function platforms(): Promise<String | undefined> {
|
||||
return await exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
|
|
|
@ -27,8 +27,7 @@ async function run(): Promise<void> {
|
|||
const buildxVersion = await buildx.getVersion();
|
||||
core.info(`📣 Buildx version: ${buildxVersion}`);
|
||||
|
||||
const builderName: string =
|
||||
inputs.driver == 'docker' ? 'default' : `builder-${process.env.GITHUB_JOB}-${(await buildx.countBuilders()) + 1}`;
|
||||
const builderName: string = inputs.driver == 'docker' ? 'default' : `builder-${require('uuid').v4()}`;
|
||||
core.setOutput('name', builderName);
|
||||
stateHelper.setBuilderName(builderName);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue