@@ -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,19 +405,20 @@ 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- );
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));
415+ });
416+
417+ const envs = {
418+ BUILDKIT_MULTI_PLATFORM: '1',
419+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP: '1',
420+ BUILDX_BAKE_GIT_AUTH_TOKEN: inpGitHubToken
421+ };
420422 await core.group(`Set envs`, async () => {
421423 core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
422424 });
@@ -443,7 +445,8 @@ jobs:
443445 overrides: [...validationOverrides, '*.secrets='],
444446 sbom: inpSbom ? `generator=${inpSbomImage}` : 'false',
445447 source: bakeSource,
446- targets: [inpTarget]
448+ targets: [inpTarget],
449+ vars: bakeVars
447450 }, {
448451 env: Object.keys(envs).length > 0 ? envs : undefined
449452 });
@@ -851,6 +854,7 @@ jobs:
851854 const os = require('os');
852855 const { Build } = require('@docker/github-builder-runtime/lib/buildx/build');
853856 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');
854858 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
855859 const { Util } = require('@docker/github-builder-runtime/lib/util');
856860
@@ -873,7 +877,7 @@ jobs:
873877 const inpSbom = core.getBooleanInput('sbom');
874878 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
875879 const inpTarget = core.getInput('target');
876- const inpVars = Util.getInputList('vars');
880+ const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false} );
877881 const inpBuildkitProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
878882
879883 const inpMetaImages = core.getMultilineInput('meta-images');
@@ -918,21 +922,20 @@ jobs:
918922 }
919923 core.setOutput('secret-dir', buildSecrets.directory);
920924
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- );
925+ const bakeVars = BakeVars.resolve(inpVars);
926+ const bakeVarKeys = bakeVars.map(value => {
927+ const idx = value.indexOf('=');
928+ return idx === -1 ? '<invalid>' : value.substring(0, idx);
929+ });
930+ await core.group(`Set bake vars`, async () => {
931+ core.info(JSON.stringify(bakeVarKeys.sort(), null, 2));
932+ core.setOutput('vars', bakeVars.join(os.EOL));
933+ });
933934
934- // Git authentication is supplied directly to the Bake action.
935- delete envs.BUILDX_BAKE_GIT_AUTH_TOKEN;
935+ const envs = {
936+ BUILDKIT_MULTI_PLATFORM: '1',
937+ BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP: '1'
938+ };
936939
937940 await core.group(`Set envs`, async () => {
938941 core.info(JSON.stringify(Object.keys(envs).sort(), null, 2));
@@ -1013,6 +1016,7 @@ jobs:
10131016 targets : ${{ steps.prepare.outputs.target }}
10141017 sbom : ${{ steps.prepare.outputs.sbom }}
10151018 set : ${{ steps.prepare.outputs.overrides }}
1019+ vars : ${{ steps.prepare.outputs.vars }}
10161020 github-token : ${{ secrets.github-token || github.token }}
10171021 env : ${{ fromJson(steps.prepare.outputs.envs || '{}') }}
10181022 -
0 commit comments