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,22 +982,33 @@ jobs:
967982 return;
968983 }
969984
985+ let digest;
970986 for (const imageName of inpImageNames) {
971- let createArgs = ['buildx', 'imagetools', 'create' ];
987+ const tags = [];
972988 for (const tag of inpTagNames) {
973- createArgs.push('-t', `${imageName}:${tag}`);
974- }
975- for (const digest of digests) {
976- createArgs.push(digest);
989+ tags.push(`${imageName}:${tag}`);
977990 }
978991 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(' ')}`);
992+ const result = await new ImageTools().create({
993+ sources: digests,
994+ tags: tags
983995 });
996+ core.info(`Created manifest with digest: ${result.digest}`);
997+ digest = result.digest;
998+ } else {
999+ let createArgs = ['buildx', 'imagetools', 'create'];
1000+ for (const tag of tags) {
1001+ createArgs.push('-t', tag);
1002+ }
1003+ for (const digest of digests) {
1004+ createArgs.push(digest);
1005+ }
1006+ core.info(`Generated command for ${imageName}: docker ${createArgs.join(' ')}`);
9841007 }
9851008 }
1009+ if (digest) {
1010+ core.setOutput('digest', digest);
1011+ }
9861012 -
9871013 name : Merge artifacts
9881014 if : ${{ inputs.output == 'local' && inputs.artifact-upload }}
0 commit comments