mirror of
https://gitea.com/docker/setup-qemu-action.git
synced 2024-11-24 02:19:32 +01:00
throw error message instead of exit code
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e2a9378e4f
commit
1765b1e310
1 changed files with 22 additions and 4 deletions
26
src/main.ts
26
src/main.ts
|
@ -20,15 +20,33 @@ actionsToolkit.run(
|
||||||
});
|
});
|
||||||
|
|
||||||
await core.group(`Pulling binfmt Docker image`, async () => {
|
await core.group(`Pulling binfmt Docker image`, async () => {
|
||||||
await Exec.exec('docker', ['pull', input.image]);
|
await Exec.getExecOutput('docker', ['pull', input.image], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await core.group(`Image info`, async () => {
|
await core.group(`Image info`, async () => {
|
||||||
await Exec.exec('docker', ['image', 'inspect', input.image]);
|
await Exec.getExecOutput('docker', ['image', 'inspect', input.image], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await core.group(`Installing QEMU static binaries`, async () => {
|
await core.group(`Installing QEMU static binaries`, async () => {
|
||||||
await Exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms]);
|
await Exec.getExecOutput('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await core.group(`Extracting available platforms`, async () => {
|
await core.group(`Extracting available platforms`, async () => {
|
||||||
|
@ -37,7 +55,7 @@ actionsToolkit.run(
|
||||||
silent: true
|
silent: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
throw new Error(res.stderr.trim());
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
}
|
}
|
||||||
const platforms: Platforms = JSON.parse(res.stdout.trim());
|
const platforms: Platforms = JSON.parse(res.stdout.trim());
|
||||||
core.info(`${platforms.supported.join(',')}`);
|
core.info(`${platforms.supported.join(',')}`);
|
||||||
|
|
Loading…
Reference in a new issue