5959 description : " Cache layers to export if cache enabled (min or max)"
6060 required : false
6161 default : ' min'
62+ compression :
63+ type : string
64+ description : " Image layer compression (uncompressed, gzip, estargz or zstd)"
65+ required : false
66+ compression-level :
67+ type : string
68+ description : " Image layer compression level (0-9 for gzip and estargz, 0-22 for zstd)"
69+ required : false
70+ force-compression :
71+ type : boolean
72+ description : " Recompress existing image layers using the selected compression type"
73+ required : false
74+ default : false
6275 context :
6376 type : string
6477 description : " Context to build from in the Git working tree"
@@ -225,6 +238,7 @@ jobs:
225238 outputs :
226239 sourceDateEpoch : ${{ steps.set.outputs.sourceDateEpoch }}
227240 sourceDateCreated : ${{ steps.set.outputs.sourceDateCreated }}
241+ buildOutput : ${{ steps.set.outputs.buildOutput }}
228242 includes : ${{ steps.set.outputs.includes }}
229243 metaImages : ${{ steps.set.outputs.metaImages }}
230244 sign : ${{ steps.set.outputs.sign }}
@@ -321,6 +335,10 @@ jobs:
321335 id : set
322336 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
323337 env :
338+ INPUT_LOCAL-EXPORT-DIR : ${{ env.LOCAL_EXPORT_DIR }}
339+ INPUT_COMPRESSION : ${{ inputs.compression }}
340+ INPUT_COMPRESSION-LEVEL : ${{ inputs.compression-level }}
341+ INPUT_FORCE-COMPRESSION : ${{ inputs.force-compression }}
324342 INPUT_SBOM-IMAGE : ${{ env.SBOM_IMAGE }}
325343 INPUT_MATRIX-SIZE-LIMIT : ${{ env.MATRIX_SIZE_LIMIT }}
326344 INPUT_META-IMAGES : ${{ inputs.meta-images }}
@@ -349,6 +367,7 @@ jobs:
349367 const { GitHub } = require('@docker/github-builder-runtime/lib/github/github');
350368 const { MetaImages } = require('@docker/github-builder-runtime/lib/github-builder/meta-images');
351369 const { SourceDateEpoch } = require('@docker/github-builder-runtime/lib/github-builder/source-date-epoch');
370+ const { BuildOutput } = require('@docker/github-builder-runtime/lib/github-builder/build-output');
352371 const { RunnerMapping } = require('@docker/github-builder-runtime/lib/github-builder/runner-mapping');
353372 const { BakeTargets } = require('@docker/github-builder-runtime/lib/github-builder/bake-targets');
354373 const { BakeVars } = require('@docker/github-builder-runtime/lib/github-builder/bake-vars');
@@ -373,6 +392,10 @@ jobs:
373392 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
374393 const inpSign = core.getInput('sign');
375394 const inpSourceDateEpoch = core.getInput('source-date-epoch');
395+ const inpCompression = core.getInput('compression');
396+ const inpCompressionLevel = core.getInput('compression-level');
397+ const inpForceCompression = core.getBooleanInput('force-compression');
398+ const inpLocalExportDir = core.getInput('local-export-dir');
376399 const inpTarget = core.getInput('target');
377400 const inpGitHubToken = core.getInput('github-token');
378401 const inpProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
@@ -429,7 +452,29 @@ jobs:
429452 }).sort(), null, 2));
430453 });
431454
455+ if (inpCompressionLevel !== '' && (!/^\d+$/.test(inpCompressionLevel) || !Number.isSafeInteger(Number(inpCompressionLevel)))) {
456+ core.setFailed(`Invalid compression-level: ${inpCompressionLevel}`);
457+ return;
458+ }
459+
432460 const metaImages = MetaImages.resolve(inpMetaImages);
461+ let buildOutput = BuildOutput.resolve({
462+ output: inpOutput,
463+ images: metaImages,
464+ push: inpPush,
465+ localExportDir: inpLocalExportDir,
466+ compression: inpCompression || undefined,
467+ compressionLevel: inpCompressionLevel !== '' ? Number(inpCompressionLevel) : undefined,
468+ forceCompression: inpForceCompression || undefined
469+ });
470+ if (inpOutput === 'image' && inpSourceDateEpoch !== '') {
471+ buildOutput += ',rewrite-timestamp=true';
472+ }
473+ await core.group(`Set buildOutput output`, async () => {
474+ core.info(buildOutput);
475+ core.setOutput('buildOutput', buildOutput);
476+ });
477+
433478 await core.group(`Set metaImages output`, async () => {
434479 core.info(JSON.stringify(metaImages, null, 2));
435480 core.setOutput('metaImages', metaImages.join('\n'));
@@ -842,23 +887,20 @@ jobs:
842887 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
843888 env :
844889 INPUT_SOURCE-DATE-EPOCH : ${{ needs.prepare.outputs.sourceDateEpoch }}
890+ INPUT_BUILD-OUTPUT : ${{ needs.prepare.outputs.buildOutput }}
845891 INPUT_PLATFORM : ${{ matrix.platform }}
846892 INPUT_SBOM-IMAGE : ${{ env.SBOM_IMAGE }}
847- INPUT_LOCAL-EXPORT-DIR : ${{ env.LOCAL_EXPORT_DIR }}
848893 INPUT_CACHE : ${{ inputs.cache }}
849894 INPUT_CACHE-SCOPE : ${{ inputs.cache-scope }}
850895 INPUT_CACHE-MODE : ${{ inputs.cache-mode }}
851896 INPUT_BUILD-SECRETS : ${{ secrets.build-secrets }}
852897 INPUT_TARGETS : ${{ needs.prepare.outputs.targets }}
853898 INPUT_CONTEXT : ${{ inputs.context }}
854899 INPUT_FILES : ${{ inputs.files }}
855- INPUT_OUTPUT : ${{ inputs.output }}
856- INPUT_PUSH : ${{ inputs.push }}
857900 INPUT_SBOM : ${{ inputs.sbom }}
858901 INPUT_SET : ${{ inputs.set }}
859902 INPUT_TARGET : ${{ inputs.target }}
860903 INPUT_VARS : ${{ inputs.vars }}
861- INPUT_META-IMAGES : ${{ needs.prepare.outputs.metaImages }}
862904 INPUT_META-VERSION : ${{ steps.meta.outputs.version }}
863905 INPUT_META-TAGS : ${{ steps.meta.outputs.tags }}
864906 INPUT_SET-META-ANNOTATIONS : ${{ inputs.set-meta-annotations }}
@@ -877,14 +919,12 @@ jobs:
877919 const { Util } = require('@docker/github-builder-runtime/lib/util');
878920
879921 const inpSourceDateEpoch = core.getInput('source-date-epoch');
880- const rewriteTimestamp = inpSourceDateEpoch !== '' ? ',rewrite-timestamp=true' : '';
881922
882923 const inpPlatform = core.getInput('platform');
883924 const platformPairSuffix = inpPlatform ? `-${inpPlatform.replace(/\//g, '-')}` : '';
884925 core.setOutput('platform-pair-suffix', platformPairSuffix);
885926
886927 const inpSbomImage = core.getInput('sbom-image');
887- const inpLocalExportDir = core.getInput('local-export-dir');
888928
889929 const inpCache = core.getBooleanInput('cache');
890930 const inpCacheScope = core.getInput('cache-scope');
@@ -893,15 +933,12 @@ jobs:
893933 const inpTargets = core.getInput('targets');
894934 const inpContext = core.getInput('context');
895935 const inpFiles = Util.getInputList('files');
896- const inpOutput = core.getInput('output');
897- const inpPush = core.getBooleanInput('push');
898936 const inpSbom = core.getBooleanInput('sbom');
899937 const inpSet = Util.getInputList('set', {ignoreComma: true, quote: false});
900938 const inpTarget = core.getInput('target');
901939 const inpVars = Util.getInputList('vars', {ignoreComma: true, quote: false});
902940 const inpBuildkitProxyNetwork = core.getBooleanInput('buildkit-proxy-network');
903941
904- const inpMetaImages = core.getMultilineInput('meta-images');
905942 const inpMetaVersion = core.getInput('meta-version');
906943 const inpMetaTags = core.getMultilineInput('meta-tags');
907944 const inpSetMetaAnnotations = core.getBooleanInput('set-meta-annotations');
@@ -970,23 +1007,6 @@ jobs:
9701007 core.setOutput('files', bakeFiles.join(os.EOL));
9711008 });
9721009
973- let outputOverride = '';
974- switch (inpOutput) {
975- case 'image':
976- if (inpMetaImages.length == 0) {
977- core.setFailed('meta-images is required when output is image');
978- return;
979- }
980- outputOverride = `*.output=type=image,"name=${inpMetaImages.join(',')}",oci-artifact=true,push-by-digest=true,name-canonical=true,push=${inpPush}${rewriteTimestamp}`;
981- break;
982- case 'local':
983- outputOverride = `*.output=type=local,platform-split=true,dest=${inpLocalExportDir}`;
984- break;
985- default:
986- core.setFailed(`Invalid output: ${inpOutput}`);
987- return;
988- }
989-
9901010 let bakeOverrides = [];
9911011 try {
9921012 bakeOverrides = inpSet.map(override => renderTemplate(override));
@@ -998,7 +1018,7 @@ jobs:
9981018 if (inpSourceDateEpoch !== '') {
9991019 bakeOverrides.push(`*.args.SOURCE_DATE_EPOCH=${inpSourceDateEpoch}`);
10001020 }
1001- bakeOverrides.push(outputOverride );
1021+ bakeOverrides.push(`*.output=${core.getInput('build-output')}` );
10021022 bakeOverrides.push('*.tags=');
10031023 if (GitHub.context.payload.repository?.private ?? false) {
10041024 // if this is a private repository, we set min provenance mode
0 commit comments