Compare commits

..

No commits in common. "0e2ab16cd236609a8fa664cd6598476d4407877b" and "563a2f55e41f590351e210f1f90838dd76263900" have entirely different histories.

6 changed files with 79 additions and 72 deletions

View File

@ -1,15 +1,12 @@
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
import {Context} from '@docker/actions-toolkit/lib/context';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {GitHub} from '@docker/actions-toolkit/lib/github';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/builder';
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
@ -38,16 +35,6 @@ jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean>
return true;
});
const metadataJson = path.join(tmpDir, 'metadata.json');
jest.spyOn(Build.prototype, 'getMetadataFilePath').mockImplementation((): string => {
return metadataJson;
});
const imageIDFilePath = path.join(tmpDir, 'iidfile.txt');
jest.spyOn(Build.prototype, 'getImageIDFilePath').mockImplementation((): string => {
return imageIDFilePath;
});
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
return {
name: 'builder2',
@ -91,7 +78,7 @@ describe('getArgs', () => {
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'.'
]
],
@ -114,7 +101,7 @@ ccc"`],
'--build-arg', 'MY_ARG=val1,val2,val3',
'--build-arg', 'ARG=val',
'--build-arg', `MULTILINE=aaaa\nbbbb\nccc`,
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'https://github.com/docker/build-push-action.git#refs/heads/master'
]
],
@ -130,7 +117,7 @@ ccc"`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--tag', 'name/app:7.4',
'--tag', 'name/app:latest',
'https://github.com/docker/build-push-action.git#refs/heads/master'
@ -185,7 +172,7 @@ ccc"`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'.'
]
],
@ -202,7 +189,7 @@ ccc"`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'.'
]
@ -243,7 +230,7 @@ ccc"`],
[
'build',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--platform', 'linux/amd64,linux/arm64',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--builder', 'builder-git-context-2',
@ -277,7 +264,7 @@ ccc"`],
[
'build',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--platform', 'linux/amd64,linux/arm64',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--secret', `id=MYSECRET,src=${tmpName}`,
@ -314,7 +301,7 @@ ccc`],
[
'build',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--platform', 'linux/amd64,linux/arm64',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--secret', `id=MYSECRET,src=${tmpName}`,
@ -343,7 +330,7 @@ ccc`],
[
'build',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--secret', `id=MY_SECRET,src=${tmpName}`,
'--builder', 'builder-git-context-2',
'--network', 'host',
@ -390,8 +377,8 @@ ccc`],
'--add-host', 'docker:10.180.0.1',
'--add-host', 'foo:10.0.0.1',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'--network', 'host',
'--push',
'.'
@ -419,11 +406,11 @@ nproc=3`],
'--add-host', 'foo:10.0.0.1',
'--cgroup-parent', 'foo',
'--file', './test/Dockerfile',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--shm-size', '2g',
'--ulimit', 'nofile=1024:1024',
'--ulimit', 'nproc=3',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -439,8 +426,8 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
]
],
@ -457,9 +444,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
]
],
@ -476,8 +463,8 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -493,9 +480,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -512,9 +499,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -531,9 +518,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -550,9 +537,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', 'type=provenance,disabled=true',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -569,9 +556,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', 'type=provenance,builder-id=foo',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -588,9 +575,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
"--output", 'type=docker',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -606,9 +593,9 @@ nproc=3`],
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--load',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -626,9 +613,9 @@ nproc=3`],
[
'build',
'--build-arg', 'FOO=bar#baz',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--load',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -648,9 +635,9 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'build',
'--secret', 'id=MY_SECRET,env=MY_SECRET_ENV',
'--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--load',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -669,9 +656,9 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'build',
'--secret', 'id=MY_SECRET,env=MY_SECRET_ENV',
'--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--load',
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -691,7 +678,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'build',
'--output', 'type=local,dest=./release-out',
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -715,7 +702,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--annotation', 'manifest-descriptor[linux/amd64]:example4=zzz',
'--output', 'type=local,dest=./release-out',
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -732,10 +719,10 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
"--output", `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`,
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -753,10 +740,10 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--attest', `type=sbom,disabled=false`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -774,9 +761,9 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],
@ -793,9 +780,9 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
]),
[
'build',
'--iidfile', imageIDFilePath,
'--iidfile', path.join(tmpDir, 'iidfile'),
'--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
'--metadata-file', metadataJson,
'--metadata-file', path.join(tmpDir, 'metadata-file'),
'.'
]
],

8
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

19
dist/licenses.txt generated vendored
View File

@ -3855,6 +3855,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
yallist
ISC
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
zip-stream
MIT
Copyright (c) 2014 Chris Talkington, contributors.

View File

@ -136,7 +136,7 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
args.push('--file', inputs.file);
}
if (!Build.hasLocalExporter(inputs.outputs) && !Build.hasTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || (await toolkit.buildx.versionSatisfies('>=0.4.2')))) {
args.push('--iidfile', toolkit.buildxBuild.getImageIDFilePath());
args.push('--iidfile', Build.getImageIDFilePath());
}
await Util.asyncForEach(inputs.labels, async label => {
args.push('--label', label);
@ -199,7 +199,7 @@ async function getCommonArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st
args.push('--load');
}
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
args.push('--metadata-file', toolkit.buildxBuild.getMetadataFilePath());
args.push('--metadata-file', Build.getMetadataFilePath());
}
if (inputs.network) {
args.push('--network', inputs.network);

View File

@ -4,6 +4,7 @@ import * as stateHelper from './state-helper';
import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit';
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
import {Context} from '@docker/actions-toolkit/lib/context';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Exec} from '@docker/actions-toolkit/lib/exec';
@ -90,9 +91,9 @@ actionsToolkit.run(
}
});
const imageID = toolkit.buildxBuild.resolveImageID();
const metadata = toolkit.buildxBuild.resolveMetadata();
const digest = toolkit.buildxBuild.resolveDigest();
const imageID = Build.resolveImageID();
const metadata = Build.resolveMetadata();
const digest = Build.resolveDigest();
if (imageID) {
await core.group(`ImageID`, async () => {