@@ -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,12 @@ 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+ await core.group(`Set bake vars`, async () => {
410+ core.info(JSON.stringify(bakeVars.map(value => {
411+ const idx = value.indexOf('=');
412+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
413+ }).sort(), null, 2));
422414 });
423415
424416 const metaImages = inpMetaImages.map(image => image.toLowerCase());
@@ -443,9 +435,14 @@ jobs:
443435 overrides: [...validationOverrides, '*.secrets='],
444436 sbom: inpSbom ? `generator=${inpSbomImage}` : 'false',
445437 source: bakeSource,
446- targets: [inpTarget]
438+ targets: [inpTarget],
439+ vars: bakeVars,
440+ githubToken: inpGitHubToken
447441 }, {
448- env: Object.keys(envs).length > 0 ? envs : undefined
442+ env: {
443+ BUILDKIT_MULTI_PLATFORM: '1',
444+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP: '1'
445+ }
449446 });
450447 if (!def) {
451448 throw new Error('Bake definition not set');
@@ -852,6 +849,7 @@ jobs:
852849 const os = require('os');
853850 const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
854851 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');
855853 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
856854 const { Util } = require('@docker/github-builder-runtime/lib/util');
857855
@@ -874,7 +872,7 @@ jobs:
874872 const inpSbom = core.getBooleanInput('sbom');
875873 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
876874 const inpTarget = core.getInput('target');
877- const inpVars = Util.getInputList('vars');
875+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
878876 const inpBuildkitProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
879877
880878 const inpMetaImages = core.getMultilineInput('meta-images');
@@ -919,27 +917,15 @@ jobs:
919917 }
920918 core.setOutput('secret-dir', buildSecrets.directory);
921919
922- const envs = Object.assign({},
923- inpVars ? inpVars.reduce((acc, curr) => {
924- const idx = curr.indexOf('=');
925- if (idx !== -1) {
926- acc[curr.substring(0, idx)] = curr.substring(idx + 1);
927- }
928- return acc;
929- }, {}) : {},
930- {
931- BUILDKIT_MULTI_PLATFORM: '1'
932- }
933- );
934-
935- // Git authentication is supplied directly to the Bake action.
936- delete envs.BUILDX_BAKE_GIT_AUTH_TOKEN;
937-
938- await core.group(`Set envs`, async () => {
939- core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
940- core.setOutput('envs', JSON.stringify(envs));
920+ const bakeVars = BakeVars.resolve(inpVars);
921+ await core.group(`Set bake vars`, async () => {
922+ core.info(JSON.stringify(bakeVars.map(value => {
923+ const idx = value.indexOf('=');
924+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
925+ }).sort(), null, 2));
926+ core.setOutput('vars', JSON.stringify(bakeVars));
941927 });
942-
928+
943929 let bakeFiles = inpFiles;
944930 await core.group(`Set bake files`, async () => {
945931 if (bakeFiles.length === 0) {
@@ -1014,8 +1000,11 @@ jobs:
10141000 targets : ${{ steps.prepare.outputs.target }}
10151001 sbom : ${{ steps.prepare.outputs.sbom }}
10161002 set : ${{ steps.prepare.outputs.overrides }}
1003+ vars : ${{ steps.prepare.outputs.vars }}
10171004 github-token : ${{ secrets.github-token || github.token }}
1018- env : ${{ fromJson(steps.prepare.outputs.envs || '{}') }}
1005+ env :
1006+ BUILDKIT_MULTI_PLATFORM : ' 1'
1007+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP : ' 1'
10191008 -
10201009 name : Remove build secrets
10211010 if : ${{ always() && steps.prepare.outputs.secret-dir != '' }}
0 commit comments