mirror of
				https://github.com/docker/build-push-action.git
				synced 2025-11-04 08:20:55 +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'
 | 
					  color: 'blue'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inputs:
 | 
					inputs:
 | 
				
			||||||
 | 
					  nofallback:
 | 
				
			||||||
 | 
					    description: "Fail the build if the remote builder is not available; defaults to false"
 | 
				
			||||||
 | 
					    required: false
 | 
				
			||||||
  add-hosts:
 | 
					  add-hosts:
 | 
				
			||||||
    description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
 | 
					    description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
 | 
				
			||||||
    required: false
 | 
					    required: false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,7 @@ export interface Inputs {
 | 
				
			||||||
  target: string;
 | 
					  target: string;
 | 
				
			||||||
  ulimit: string[];
 | 
					  ulimit: string[];
 | 
				
			||||||
  'github-token': string;
 | 
					  'github-token': string;
 | 
				
			||||||
 | 
					  nofallback: boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function getInputs(): Promise<Inputs> {
 | 
					export async function getInputs(): Promise<Inputs> {
 | 
				
			||||||
| 
						 | 
					@ -75,7 +76,8 @@ export async function getInputs(): Promise<Inputs> {
 | 
				
			||||||
    tags: Util.getInputList('tags'),
 | 
					    tags: Util.getInputList('tags'),
 | 
				
			||||||
    target: core.getInput('target'),
 | 
					    target: core.getInput('target'),
 | 
				
			||||||
    ulimit: Util.getInputList('ulimit', {ignoreComma: true}),
 | 
					    ulimit: Util.getInputList('ulimit', {ignoreComma: true}),
 | 
				
			||||||
    'github-token': core.getInput('github-token')
 | 
					    'github-token': core.getInput('github-token'),
 | 
				
			||||||
 | 
					    nofallback: core.getBooleanInput('nofallback')
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,9 @@ async function getRemoteBuilderAddr(inputs: context.Inputs): Promise<string | nu
 | 
				
			||||||
    return null;
 | 
					    return null;
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    if (error.response && error.response.status === 404) {
 | 
					    if (error.response && error.response.status === 404) {
 | 
				
			||||||
 | 
					      if (!inputs.nofallback) {
 | 
				
			||||||
        core.warning('No builder instances were available, falling back to a local build');
 | 
					        core.warning('No builder instances were available, falling back to a local build');
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      core.warning(`Error in getBuildkitdAddr: ${error.message}`);
 | 
					      core.warning(`Error in getBuildkitdAddr: ${error.message}`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -171,8 +173,12 @@ actionsToolkit.run(
 | 
				
			||||||
    await core.group(`Starting Blacksmith remote builder`, async () => {
 | 
					    await core.group(`Starting Blacksmith remote builder`, async () => {
 | 
				
			||||||
      remoteBuilderAddr = await getRemoteBuilderAddr(inputs);
 | 
					      remoteBuilderAddr = await getRemoteBuilderAddr(inputs);
 | 
				
			||||||
      if (!remoteBuilderAddr) {
 | 
					      if (!remoteBuilderAddr) {
 | 
				
			||||||
 | 
					        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.');
 | 
					          core.warning('Failed to obtain Blacksmith remote builder address. Falling back to a local build.');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (remoteBuilderAddr) {
 | 
					    if (remoteBuilderAddr) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue