@@ -342,6 +342,7 @@ jobs:
342342 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
343343 const { RunnerMapping } = require('@docker/github-builder-runtime/lib/github-builder/runner-mapping');
344344 const { BakeTargets } = require('@docker/github-builder-runtime/lib/github-builder/bake-targets');
345+ const { BakeVars } = require('@docker/github-builder-runtime/lib/github-builder/bake-vars');
345346 const { Util } = require('@docker/github-builder-runtime/lib/util');
346347
347348 const inpSbomImage = core.getInput('sbom-image');
@@ -354,7 +355,7 @@ jobs:
354355 const inpArtifactUpload = core.getBooleanInput('artifact-upload');
355356 const inpJobNamePrefix = core.getInput('job-name-prefix');
356357 const inpContext = core.getInput('context');
357- const inpVars = Util.getInputList('vars');
358+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
358359 const inpFiles = Util.getInputList('files');
359360 const inpOutput = core.getInput('output');
360361 const inpPush = core.getBooleanInput('push');
@@ -404,21 +405,13 @@ jobs:
404405 }
405406 const registryLogin = inpRegistryLogin === 'auto' ? inpOutput === 'image' && inpPush : inpRegistryLogin === 'true';
406407
407- const envs = Object.assign({},
408- inpVars ? inpVars.reduce((acc, curr) => {
409- const idx = curr.indexOf('=');
410- if (idx !== -1) {
411- acc[curr.substring(0, idx)] = curr.substring(idx + 1);
412- }
413- return acc;
414- }, {}) : {},
415- {
416- BUILDKIT_MULTI_PLATFORM: '1',
417- BUILDX_BAKE_GIT_AUTH_TOKEN: inpGitHubToken
418- }
419- );
420- await core.group(`Set envs`, async () => {
421- core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
408+ const bakeVars = BakeVars.resolve(inpVars);
409+ const bakeVarKeys = bakeVars.map(value => {
410+ const idx = value.indexOf('=');
411+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
412+ });
413+ await core.group(`Set bake vars`, async () => {
414+ core.info(JSON.stringify(bakeVarKeys.sort(), null, 2));
422415 });
423416
424417 const metaImages = inpMetaImages.map(image => image.toLowerCase());
@@ -443,9 +436,14 @@ jobs:
443436 overrides: [...validationOverrides, '*.secrets='],
444437 sbom: inpSbom ? `generator=${inpSbomImage}` : 'false',
445438 source: bakeSource,
446- targets: [inpTarget]
439+ targets: [inpTarget],
440+ vars: bakeVars,
441+ githubToken: inpGitHubToken
447442 }, {
448- env: Object.keys(envs).length > 0 ? envs : undefined
443+ env: {
444+ BUILDKIT_MULTI_PLATFORM: '1',
445+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP: '1'
446+ }
449447 });
450448 if (!def) {
451449 throw new Error('Bake definition not set');
@@ -851,6 +849,7 @@ jobs:
851849 const os = require('os');
852850 const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
853851 const { BuildSecrets } = require('@docker/github-builder-runtime/lib/github-builder/build-secrets');
852+ const { BakeVars } = require('@docker/github-builder-runtime/lib/github-builder/bake-vars');
854853 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
855854 const { Util } = require('@docker/github-builder-runtime/lib/util');
856855
@@ -873,7 +872,7 @@ jobs:
873872 const inpSbom = core.getBooleanInput('sbom');
874873 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
875874 const inpTarget = core.getInput('target');
876- const inpVars = Util.getInputList('vars');
875+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
877876 const inpBuildkitProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
878877
879878 const inpMetaImages = core.getMultilineInput('meta-images');
@@ -918,27 +917,16 @@ jobs:
918917 }
919918 core.setOutput('secret-dir', buildSecrets.directory);
920919
921- const envs = Object.assign({},
922- inpVars ? inpVars.reduce((acc, curr) => {
923- const idx = curr.indexOf('=');
924- if (idx !== -1) {
925- acc[curr.substring(0, idx)] = curr.substring(idx + 1);
926- }
927- return acc;
928- }, {}) : {},
929- {
930- BUILDKIT_MULTI_PLATFORM: '1'
931- }
932- );
933-
934- // Git authentication is supplied directly to the Bake action.
935- delete envs.BUILDX_BAKE_GIT_AUTH_TOKEN;
936-
937- await core.group(`Set envs`, async () => {
938- core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
939- core.setOutput('envs', JSON.stringify(envs));
920+ const bakeVars = BakeVars.resolve(inpVars);
921+ const bakeVarKeys = bakeVars.map(value => {
922+ const idx = value.indexOf('=');
923+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
940924 });
941-
925+ await core.group(`Set bake vars`, async () => {
926+ core.info(JSON.stringify(bakeVarKeys.sort(), null, 2));
927+ core.setOutput('vars', bakeVars.join(os.EOL));
928+ });
929+
942930 let bakeFiles = inpFiles;
943931 await core.group(`Set bake files`, async () => {
944932 if (bakeFiles.length === 0) {
@@ -1013,8 +1001,11 @@ jobs:
10131001 targets : ${{ steps.prepare.outputs.target }}
10141002 sbom : ${{ steps.prepare.outputs.sbom }}
10151003 set : ${{ steps.prepare.outputs.overrides }}
1004+ vars : ${{ steps.prepare.outputs.vars }}
10161005 github-token : ${{ secrets.github-token || github.token }}
1017- env : ${{ fromJson(steps.prepare.outputs.envs || '{}') }}
1006+ env :
1007+ BUILDKIT_MULTI_PLATFORM : ' 1'
1008+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP : ' 1'
10181009 -
10191010 name : Remove build secrets
10201011 if : ${{ always() && steps.prepare.outputs.secret-dir != '' }}
0 commit comments