@@ -347,6 +347,7 @@ jobs:
347347 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
348348 const { RunnerMapping } = require('@docker/github-builder-runtime/lib/github-builder/runner-mapping');
349349 const { BakeTargets } = require('@docker/github-builder-runtime/lib/github-builder/bake-targets');
350+ const { BakeVars } = require('@docker/github-builder-runtime/lib/github-builder/bake-vars');
350351 const { Util } = require('@docker/github-builder-runtime/lib/util');
351352
352353 const inpSbomImage = core.getInput('sbom-image');
@@ -359,7 +360,7 @@ jobs:
359360 const inpArtifactUpload = core.getBooleanInput('artifact-upload');
360361 const inpJobNamePrefix = core.getInput('job-name-prefix');
361362 const inpContext = core.getInput('context');
362- const inpVars = Util.getInputList('vars');
363+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
363364 const inpFiles = Util.getInputList('files');
364365 const inpOutput = core.getInput('output');
365366 const inpPush = core.getBooleanInput('push');
@@ -409,21 +410,12 @@ jobs:
409410 }
410411 const registryLogin = inpRegistryLogin === 'auto' ? inpOutput === 'image' && inpPush : inpRegistryLogin === 'true';
411412
412- const envs = Object.assign({},
413- inpVars ? inpVars.reduce((acc, curr) => {
414- const idx = curr.indexOf('=');
415- if (idx !== -1) {
416- acc[curr.substring(0, idx)] = curr.substring(idx + 1);
417- }
418- return acc;
419- }, {}) : {},
420- {
421- BUILDKIT_MULTI_PLATFORM: '1',
422- BUILDX_BAKE_GIT_AUTH_TOKEN: inpGitHubToken
423- }
424- );
425- await core.group(`Set envs`, async () => {
426- core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
413+ const bakeVars = BakeVars.resolve(inpVars);
414+ await core.group(`Set bake vars`, async () => {
415+ core.info(JSON.stringify(bakeVars.map(value => {
416+ const idx = value.indexOf('=');
417+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
418+ }).sort(), null, 2));
427419 });
428420
429421 const metaImages = inpMetaImages.map(image => image.toLowerCase());
@@ -448,9 +440,14 @@ jobs:
448440 overrides: [...validationOverrides, '*.secrets='],
449441 sbom: inpSbom ? `generator=${inpSbomImage}` : 'false',
450442 source: bakeSource,
451- targets: [inpTarget]
443+ targets: [inpTarget],
444+ vars: bakeVars,
445+ githubToken: inpGitHubToken
452446 }, {
453- env: Object.keys(envs).length > 0 ? envs : undefined
447+ env: {
448+ BUILDKIT_MULTI_PLATFORM: '1',
449+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP: '1'
450+ }
454451 });
455452 if (!def) {
456453 throw new Error('Bake definition not set');
@@ -857,6 +854,7 @@ jobs:
857854 const os = require('os');
858855 const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
859856 const { BuildSecrets } = require('@docker/github-builder-runtime/lib/github-builder/build-secrets');
857+ const { BakeVars } = require('@docker/github-builder-runtime/lib/github-builder/bake-vars');
860858 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
861859 const { Util } = require('@docker/github-builder-runtime/lib/util');
862860
@@ -879,7 +877,7 @@ jobs:
879877 const inpSbom = core.getBooleanInput('sbom');
880878 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
881879 const inpTarget = core.getInput('target');
882- const inpVars = Util.getInputList('vars');
880+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
883881 const inpBuildkitProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
884882
885883 const inpMetaImages = core.getMultilineInput('meta-images');
@@ -924,27 +922,15 @@ jobs:
924922 }
925923 core.setOutput('secret-dir', buildSecrets.directory);
926924
927- const envs = Object.assign({},
928- inpVars ? inpVars.reduce((acc, curr) => {
929- const idx = curr.indexOf('=');
930- if (idx !== -1) {
931- acc[curr.substring(0, idx)] = curr.substring(idx + 1);
932- }
933- return acc;
934- }, {}) : {},
935- {
936- BUILDKIT_MULTI_PLATFORM: '1'
937- }
938- );
939-
940- // Git authentication is supplied directly to the Bake action.
941- delete envs.BUILDX_BAKE_GIT_AUTH_TOKEN;
942-
943- await core.group(`Set envs`, async () => {
944- core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
945- core.setOutput('envs', JSON.stringify(envs));
925+ const bakeVars = BakeVars.resolve(inpVars);
926+ await core.group(`Set bake vars`, async () => {
927+ core.info(JSON.stringify(bakeVars.map(value => {
928+ const idx = value.indexOf('=');
929+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
930+ }).sort(), null, 2));
931+ core.setOutput('vars', JSON.stringify(bakeVars));
946932 });
947-
933+
948934 let bakeFiles = inpFiles;
949935 await core.group(`Set bake files`, async () => {
950936 if (bakeFiles.length === 0) {
@@ -1019,8 +1005,11 @@ jobs:
10191005 targets : ${{ steps.prepare.outputs.target }}
10201006 sbom : ${{ steps.prepare.outputs.sbom }}
10211007 set : ${{ steps.prepare.outputs.overrides }}
1008+ vars : ${{ steps.prepare.outputs.vars }}
10221009 github-token : ${{ secrets.github-token || github.token }}
1023- env : ${{ fromJson(steps.prepare.outputs.envs || '{}') }}
1010+ env :
1011+ BUILDKIT_MULTI_PLATFORM : ' 1'
1012+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP : ' 1'
10241013 -
10251014 name : Remove build secrets
10261015 if : ${{ always() && steps.prepare.outputs.secret-dir != '' }}
0 commit comments