Skip to content

Commit

Permalink
Throw error message instead of exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed May 14, 2021
1 parent 1882cef commit 06bfe5c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -56,7 +56,27 @@ jobs:
if: always()
uses: crazy-max/ghaction-dump-context@v1

error:
error-msg:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
continue-on-error: true
uses: ./
with:
files: |
./test/config.hcl
set: |
*.platform=linux/amd64,linux/ppc64le,linux/s390x
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

error-check:
runs-on: ubuntu-latest
steps:
-
Expand Down
10 changes: 8 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/exec.ts
Expand Up @@ -7,7 +7,7 @@ export interface ExecResult {
stderr: string;
}

export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
export const exec = async (command: string, args: string[] = [], silent?: boolean): Promise<ExecResult> => {
let stdout: string = '';
let stderr: string = '';

Expand Down
10 changes: 8 additions & 2 deletions src/main.ts
@@ -1,5 +1,6 @@
import * as buildx from './buildx';
import * as context from './context';
import * as mexec from './exec';
import * as core from '@actions/core';
import * as exec from '@actions/exec';

Expand All @@ -25,8 +26,13 @@ async function run(): Promise<void> {
await exec.exec('docker', [...args, '--print']);
core.endGroup();

core.info(`Building...`);
await exec.exec('docker', args);
await core.group(`Building`, async () => {
await mexec.exec('docker', args).then(res => {
if (res.stderr.length > 0 && !res.success) {
core.error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)![0]}`);
}
});
});
} catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit 06bfe5c

Please sign in to comment.