@@ -88,24 +88,25 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
8888}
8989
9090export async function getArgs ( inputs : Inputs , defaultContext : string , buildxVersion : string ) : Promise < Array < string > > {
91- let args : Array < string > = [ 'buildx' ] ;
92- args . push . apply ( args , await getBuildArgs ( inputs , defaultContext , buildxVersion ) ) ;
93- args . push . apply ( args , await getCommonArgs ( inputs ) ) ;
94- args . push ( inputs . context ) ;
95- return args ;
91+ return [
92+ 'buildx' ,
93+ ...await getBuildArgs ( inputs , defaultContext , buildxVersion ) ,
94+ ...await getCommonArgs ( inputs ) ,
95+ inputs . context ,
96+ ] ;
9697}
9798
9899async function getBuildArgs ( inputs : Inputs , defaultContext : string , buildxVersion : string ) : Promise < Array < string > > {
99- let args : Array < string > = [ 'build' ] ;
100- await asyncForEach ( inputs . buildArgs , async buildArg => {
101- args . push ( '--build-arg' , buildArg ) ;
102- } ) ;
103- await asyncForEach ( inputs . labels , async label => {
104- args . push ( '--label' , label ) ;
105- } ) ;
106- await asyncForEach ( inputs . tags , async tag => {
107- args . push ( '--tag' , tag ) ;
108- } ) ;
100+ const args : Array < string > = [ 'build' ] . concat (
101+ ... flagMap ( inputs . buildArgs , '--build-arg' ) ,
102+ ... flagMap ( inputs . cacheFrom , '--cache-from' ) ,
103+ ... flagMap ( inputs . cacheTo , '--cache-to' ) ,
104+ ... flagMap ( inputs . labels , '-- label' ) ,
105+ ... flagMap ( inputs . outputs , '--output' ) ,
106+ ... flagMap ( inputs . tags , '--tag' ) ,
107+ ... flagMap ( inputs . ssh , '--ssh' ) ,
108+ ) ;
109+
109110 if ( inputs . target ) {
110111 args . push ( '--target' , inputs . target ) ;
111112 }
@@ -115,9 +116,6 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
115116 if ( inputs . platforms . length > 0 ) {
116117 args . push ( '--platform' , inputs . platforms . join ( ',' ) ) ;
117118 }
118- await asyncForEach ( inputs . outputs , async output => {
119- args . push ( '--output' , output ) ;
120- } ) ;
121119 if ( ! buildx . isLocalOrTarExporter ( inputs . outputs ) && ( inputs . platforms . length == 0 || buildx . satisfies ( buildxVersion , '>=0.4.2' ) ) ) {
122120 args . push ( '--iidfile' , await buildx . getImageIDFile ( ) ) ;
123121 }
@@ -147,9 +145,6 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
147145 if ( inputs . githubToken && ! buildx . hasGitAuthToken ( inputs . secrets ) && inputs . context == defaultContext ) {
148146 args . push ( '--secret' , await buildx . getSecretString ( `GIT_AUTH_TOKEN=${ inputs . githubToken } ` ) ) ;
149147 }
150- await asyncForEach ( inputs . ssh , async ssh => {
151- args . push ( '--ssh' , ssh ) ;
152- } ) ;
153148 if ( inputs . file ) {
154149 args . push ( '--file' , inputs . file ) ;
155150 }
@@ -212,6 +207,10 @@ export const asyncForEach = async (array, callback) => {
212207 }
213208} ;
214209
210+ export function flagMap ( array : string [ ] , flag : string ) : string [ ] [ ] {
211+ return array . map ( value => [ flag , value ] ) ;
212+ }
213+
215214// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
216215export function setOutput ( name : string , value : any ) : void {
217216 issueCommand ( 'set-output' , { name} , value ) ;
0 commit comments