mirror of
https://github.com/docker/build-push-action.git
synced 2025-03-28 16:21:01 +00:00
add a fallback
input
This commit is contained in:
parent
84699d113f
commit
b61cd1c338
3 changed files with 14 additions and 3 deletions
|
@ -7,6 +7,9 @@ branding:
|
|||
color: 'blue'
|
||||
|
||||
inputs:
|
||||
nofallback:
|
||||
description: "Fail the build if the remote builder is not available; defaults to false"
|
||||
required: false
|
||||
add-hosts:
|
||||
description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
|
||||
required: false
|
||||
|
|
|
@ -40,6 +40,7 @@ export interface Inputs {
|
|||
target: string;
|
||||
ulimit: string[];
|
||||
'github-token': string;
|
||||
nofallback: boolean;
|
||||
}
|
||||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
|
@ -75,7 +76,8 @@ export async function getInputs(): Promise<Inputs> {
|
|||
tags: Util.getInputList('tags'),
|
||||
target: core.getInput('target'),
|
||||
ulimit: Util.getInputList('ulimit', {ignoreComma: true}),
|
||||
'github-token': core.getInput('github-token')
|
||||
'github-token': core.getInput('github-token'),
|
||||
nofallback: core.getBooleanInput('nofallback')
|
||||
};
|
||||
}
|
||||
|
||||
|
|
10
src/main.ts
10
src/main.ts
|
@ -97,7 +97,9 @@ async function getRemoteBuilderAddr(inputs: context.Inputs): Promise<string | nu
|
|||
return null;
|
||||
} catch (error) {
|
||||
if (error.response && error.response.status === 404) {
|
||||
core.warning('No builder instances were available, falling back to a local build');
|
||||
if (!inputs.nofallback) {
|
||||
core.warning('No builder instances were available, falling back to a local build');
|
||||
}
|
||||
} else {
|
||||
core.warning(`Error in getBuildkitdAddr: ${error.message}`);
|
||||
}
|
||||
|
@ -171,7 +173,11 @@ actionsToolkit.run(
|
|||
await core.group(`Starting Blacksmith remote builder`, async () => {
|
||||
remoteBuilderAddr = await getRemoteBuilderAddr(inputs);
|
||||
if (!remoteBuilderAddr) {
|
||||
core.warning('Failed to obtain Blacksmith remote builder address. Falling back to a local build.');
|
||||
if (inputs.nofallback) {
|
||||
core.setFailed('Failed to obtain Blacksmith builder. Failing the build');
|
||||
} else {
|
||||
core.warning('Failed to obtain Blacksmith remote builder address. Falling back to a local build.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue