(inputs: Inputs, context: string, toolkit: Toolkit)
| 98 | } |
| 99 | |
| 100 | async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): Promise<Array<string>> { |
| 101 | const defaultContext = await getDefaultContext(); |
| 102 | |
| 103 | const args: Array<string> = ['build']; |
| 104 | await Util.asyncForEach(inputs['add-hosts'], async addHost => { |
| 105 | args.push('--add-host', addHost); |
| 106 | }); |
| 107 | await Util.asyncForEach(inputs.allow, async allow => { |
| 108 | args.push('--allow', allow); |
| 109 | }); |
| 110 | if (await toolkit.buildx.versionSatisfies('>=0.12.0')) { |
| 111 | await Util.asyncForEach(inputs.annotations, async annotation => { |
| 112 | args.push('--annotation', annotation); |
| 113 | }); |
| 114 | } else if (inputs.annotations.length > 0) { |
| 115 | core.warning("Annotations are only supported by buildx >= 0.12.0; the input 'annotations' is ignored."); |
| 116 | } |
| 117 | await Util.asyncForEach(inputs['build-args'], async buildArg => { |
| 118 | args.push('--build-arg', buildArg); |
| 119 | }); |
| 120 | if (await toolkit.buildx.versionSatisfies('>=0.8.0')) { |
| 121 | await Util.asyncForEach(inputs['build-contexts'], async buildContext => { |
| 122 | args.push( |
| 123 | '--build-context', |
| 124 | handlebars.compile(buildContext)({ |
| 125 | defaultContext: defaultContext |
| 126 | }) |
| 127 | ); |
| 128 | }); |
| 129 | } else if (inputs['build-contexts'].length > 0) { |
| 130 | core.warning("Build contexts are only supported by buildx >= 0.8.0; the input 'build-contexts' is ignored."); |
| 131 | } |
| 132 | await Util.asyncForEach(inputs['cache-from'], async cacheFrom => { |
| 133 | args.push('--cache-from', cacheFrom); |
| 134 | }); |
| 135 | await Util.asyncForEach(inputs['cache-to'], async cacheTo => { |
| 136 | args.push('--cache-to', cacheTo); |
| 137 | }); |
| 138 | if (inputs.call) { |
| 139 | if (!(await toolkit.buildx.versionSatisfies('>=0.15.0'))) { |
| 140 | throw new Error(`Buildx >= 0.15.0 is required to use the call flag.`); |
| 141 | } |
| 142 | args.push('--call', inputs.call); |
| 143 | } |
| 144 | if (inputs['cgroup-parent']) { |
| 145 | args.push('--cgroup-parent', inputs['cgroup-parent']); |
| 146 | } |
| 147 | await Util.asyncForEach(inputs['secret-envs'], async secretEnv => { |
| 148 | try { |
| 149 | args.push('--secret', Build.resolveSecretEnv(secretEnv)); |
| 150 | } catch (err) { |
| 151 | core.warning(err.message); |
| 152 | } |
| 153 | }); |
| 154 | if (inputs.file) { |
| 155 | args.push('--file', inputs.file); |
| 156 | } |
| 157 | if (!Build.hasLocalExporter(inputs.outputs) && !Build.hasTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || (await toolkit.buildx.versionSatisfies('>=0.4.2')))) { |
no test coverage detected