call input to set method for evaluating build

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-11-25 17:14:29 +01:00
parent 5e99dacf67
commit 75ffdcce88
No known key found for this signature in database
GPG key ID: ADE44D8C9D44FBE4
5 changed files with 52 additions and 4 deletions

View file

@ -17,6 +17,7 @@ export interface Inputs {
builder: string;
'cache-from': string[];
'cache-to': string[];
call: string;
'cgroup-parent': string;
context: string;
file: string;
@ -53,6 +54,7 @@ export async function getInputs(): Promise<Inputs> {
builder: core.getInput('builder'),
'cache-from': Util.getInputList('cache-from', {ignoreComma: true}),
'cache-to': Util.getInputList('cache-to', {ignoreComma: true}),
call: core.getInput('call'),
'cgroup-parent': core.getInput('cgroup-parent'),
context: core.getInput('context') || Context.gitContext(),
file: core.getInput('file'),
@ -141,6 +143,12 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
await Util.asyncForEach(inputs['cache-to'], async cacheTo => {
args.push('--cache-to', cacheTo);
});
if (inputs.call) {
if (!(await toolkit.buildx.versionSatisfies('>=0.15.0'))) {
throw new Error(`Buildx >= 0.15.0 is required to use the call flag.`);
}
args.push('--call', inputs.call);
}
if (inputs['cgroup-parent']) {
args.push('--cgroup-parent', inputs['cgroup-parent']);
}

View file

@ -104,8 +104,14 @@ actionsToolkit.run(
[key: string]: string;
}
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
if (res.exitCode != 0) {
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
// take the first line with the message summaryzing the warnings
err = Error(res.stdout.split('\n')[0]?.trim());
} else if (res.stderr.length > 0) {
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
}
}
});
@ -161,6 +167,8 @@ actionsToolkit.run(
await core.group(`Check build summary support`, async () => {
if (!buildSummaryEnabled()) {
core.info('Build summary disabled');
} else if (inputs.call && inputs.call !== 'build') {
core.info(`Build summary skipped for ${inputs.call} subrequest`);
} else if (GitHub.isGHES) {
core.info('Build summary is not yet supported on GHES');
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {