138138 artifact-name :
139139 description : " Name of the uploaded artifact (for local output)"
140140 value : ${{ jobs.finalize.outputs.artifact-name }}
141+ image-digest :
142+ description : " Digest of the built image (for image output if pushed)"
143+ value : ${{ jobs.finalize.outputs.image-digest }}
141144 output-type :
142145 description : " Build output type"
143146 value : ${{ jobs.finalize.outputs.output-type }}
@@ -904,12 +907,21 @@ jobs:
904907 cosign-version : ${{ env.COSIGN_VERSION }}
905908 cosign-verify-commands : ${{ steps.set.outputs.cosign-verify-commands }}
906909 artifact-name : ${{ inputs.artifact-upload && inputs.artifact-name || '' }}
910+ image-digest : ${{ steps.manifest.outputs.digest }}
907911 output-type : ${{ inputs.output }}
908912 signed : ${{ needs.prepare.outputs.sign }}
909913 needs :
910914 - prepare
911915 - build
912916 steps :
917+ -
918+ name : Install @docker/actions-toolkit
919+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
920+ env :
921+ INPUT_DAT-MODULE : ${{ env.DOCKER_ACTIONS_TOOLKIT_MODULE }}
922+ with :
923+ script : |
924+ await exec.exec('npm', ['install', '--prefer-offline', '--ignore-scripts', core.getInput('dat-module')]);
913925 -
914926 name : Docker meta
915927 id : meta
@@ -941,6 +953,7 @@ jobs:
941953 cache-binary : false
942954 -
943955 name : Create manifest
956+ id : manifest
944957 if : ${{ inputs.output == 'image' }}
945958 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
946959 env :
@@ -950,6 +963,8 @@ jobs:
950963 INPUT_BUILD-OUTPUTS : ${{ toJSON(needs.build.outputs) }}
951964 with :
952965 script : |
966+ const { ImageTools } = require('@docker/actions-toolkit/lib/buildx/imagetools');
967+
953968 const inpPush = core.getBooleanInput('push');
954969 const inpImageNames = core.getMultilineInput('image-names');
955970 const inpTagNames = core.getMultilineInput('tag-names');
@@ -967,21 +982,29 @@ jobs:
967982 return;
968983 }
969984
985+ const tags = [];
970986 for (const imageName of inpImageNames) {
987+ for (const tag of inpTagNames) {
988+ tags.push(`${imageName}:${tag}`);
989+ }
990+ }
991+
992+ if (inpPush) {
993+ const result = await new ImageTools().create({
994+ sources: digests,
995+ tags: tags
996+ });
997+ core.info(`Created manifest with digest: ${result.digest}`);
998+ core.setOutput('digest', result.digest);
999+ } else {
9711000 let createArgs = ['buildx', 'imagetools', 'create'];
9721001 for (const tag of inpTagNames) {
9731002 createArgs.push('-t', `${imageName}:${tag}`);
9741003 }
9751004 for (const digest of digests) {
9761005 createArgs.push(digest);
9771006 }
978- if (inpPush) {
979- await exec.exec('docker', createArgs);
980- } else {
981- await core.group(`Generated imagetools create command for ${imageName}`, async () => {
982- core.info(`docker ${createArgs.join(' ')}`);
983- });
984- }
1007+ core.info(`Generated command: docker ${createArgs.join(' ')}`);
9851008 }
9861009 -
9871010 name : Merge artifacts
0 commit comments