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

Throw error message instead of exit code #25

Merged
merged 1 commit into from May 14, 2021
Merged
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
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
16 changes: 10 additions & 6 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
16 changes: 10 additions & 6 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 @@ -15,18 +16,21 @@ async function run(): Promise<void> {
return;
}

const buildxVersion = await buildx.getVersion();
core.info(`Using buildx ${buildxVersion}`);
const bxVersion = await buildx.getVersion();
core.debug(`buildx version: ${bxVersion}`);

let inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, buildxVersion);
const inputs: context.Inputs = await context.getInputs();
const args: string[] = await context.getArgs(inputs, bxVersion);

core.startGroup(`Bake definition`);
await exec.exec('docker', [...args, '--print']);
core.endGroup();

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