Skip to content

Commit

Permalink
Merge pull request #129 from crazy-max/fxi-err-message
Browse files Browse the repository at this point in the history
throw error message instead of exit code
  • Loading branch information
tonistiigi authored Apr 15, 2024
2 parents e2a9378 + 4d56188 commit b724902
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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.

26 changes: 22 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,33 @@ actionsToolkit.run(
});

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 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 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 () => {
Expand All @@ -37,7 +55,7 @@ actionsToolkit.run(
silent: true
}).then(res => {
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());
core.info(`${platforms.supported.join(',')}`);
Expand Down

0 comments on commit b724902

Please sign in to comment.