mirror of
https://github.com/docker/build-push-action.git
synced 2024-12-24 07:42:14 -05:00
use new implementation from toolkit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
7e3a79c50d
commit
a54198e85a
3 changed files with 15 additions and 14 deletions
|
@ -609,7 +609,7 @@ nproc=3`],
|
|||
jest.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||
return buildxVersion;
|
||||
});
|
||||
const inp = await context.getInputs(toolkit);
|
||||
const inp = await context.getInputs();
|
||||
const res = await context.getArgs(inp, toolkit);
|
||||
expect(res).toEqual(expected);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ export interface Inputs {
|
|||
githubToken: string;
|
||||
}
|
||||
|
||||
export async function getInputs(toolkit: Toolkit): Promise<Inputs> {
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
return {
|
||||
addHosts: Util.getInputList('add-hosts'),
|
||||
allow: Util.getInputList('allow'),
|
||||
|
@ -59,7 +59,7 @@ export async function getInputs(toolkit: Toolkit): Promise<Inputs> {
|
|||
noCacheFilters: Util.getInputList('no-cache-filters'),
|
||||
outputs: Util.getInputList('outputs', {ignoreComma: true}),
|
||||
platforms: Util.getInputList('platforms'),
|
||||
provenance: toolkit.buildx.inputs.getProvenanceInput('provenance'),
|
||||
provenance: BuildxInputs.getProvenanceInput('provenance'),
|
||||
pull: core.getBooleanInput('pull'),
|
||||
push: core.getBooleanInput('push'),
|
||||
sbom: core.getInput('sbom'),
|
||||
|
@ -120,7 +120,7 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
|||
args.push('--file', inputs.file);
|
||||
}
|
||||
if (!BuildxInputs.hasLocalExporter(inputs.outputs) && !BuildxInputs.hasTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || (await toolkit.buildx.versionSatisfies('>=0.4.2')))) {
|
||||
args.push('--iidfile', toolkit.buildx.inputs.getBuildImageIDFilePath());
|
||||
args.push('--iidfile', BuildxInputs.getBuildImageIDFilePath());
|
||||
}
|
||||
await Util.asyncForEach(inputs.labels, async label => {
|
||||
args.push('--label', label);
|
||||
|
@ -144,10 +144,10 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
|||
if (GitHub.context.payload.repository?.private ?? false) {
|
||||
// if this is a private repository, we set the default provenance
|
||||
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
|
||||
args.push('--provenance', toolkit.buildx.inputs.resolveProvenanceAttrs(`mode=min,inline-only=true`));
|
||||
args.push('--provenance', BuildxInputs.resolveProvenanceAttrs(`mode=min,inline-only=true`));
|
||||
} else {
|
||||
// for a public repository, we set max provenance mode.
|
||||
args.push('--provenance', toolkit.buildx.inputs.resolveProvenanceAttrs(`mode=max`));
|
||||
args.push('--provenance', BuildxInputs.resolveProvenanceAttrs(`mode=max`));
|
||||
}
|
||||
}
|
||||
if (inputs.sbom) {
|
||||
|
@ -156,20 +156,20 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
|||
}
|
||||
await Util.asyncForEach(inputs.secrets, async secret => {
|
||||
try {
|
||||
args.push('--secret', toolkit.buildx.inputs.resolveBuildSecretString(secret));
|
||||
args.push('--secret', BuildxInputs.resolveBuildSecretString(secret));
|
||||
} catch (err) {
|
||||
core.warning(err.message);
|
||||
}
|
||||
});
|
||||
await Util.asyncForEach(inputs.secretFiles, async secretFile => {
|
||||
try {
|
||||
args.push('--secret', toolkit.buildx.inputs.resolveBuildSecretFile(secretFile));
|
||||
args.push('--secret', BuildxInputs.resolveBuildSecretFile(secretFile));
|
||||
} catch (err) {
|
||||
core.warning(err.message);
|
||||
}
|
||||
});
|
||||
if (inputs.githubToken && !BuildxInputs.hasGitAuthTokenSecret(inputs.secrets) && context.startsWith(Context.gitContext())) {
|
||||
args.push('--secret', toolkit.buildx.inputs.resolveBuildSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
||||
args.push('--secret', BuildxInputs.resolveBuildSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
||||
}
|
||||
if (inputs.shmSize) {
|
||||
args.push('--shm-size', inputs.shmSize);
|
||||
|
@ -198,7 +198,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.buildx.inputs.getBuildMetadataFilePath());
|
||||
args.push('--metadata-file', BuildxInputs.getBuildMetadataFilePath());
|
||||
}
|
||||
if (inputs.network) {
|
||||
args.push('--network', inputs.network);
|
||||
|
|
|
@ -6,6 +6,7 @@ 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';
|
||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||
import {Inputs as BuildxInputs} from '@docker/actions-toolkit/lib/buildx/inputs';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
|
||||
import * as context from './context';
|
||||
|
@ -13,8 +14,8 @@ import * as context from './context';
|
|||
actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
const inputs: context.Inputs = await context.getInputs();
|
||||
const toolkit = new Toolkit();
|
||||
const inputs: context.Inputs = await context.getInputs(toolkit);
|
||||
|
||||
await core.group(`GitHub Actions runtime token ACs`, async () => {
|
||||
try {
|
||||
|
@ -54,9 +55,9 @@ actionsToolkit.run(
|
|||
}
|
||||
});
|
||||
|
||||
const imageID = await toolkit.buildx.inputs.resolveBuildImageID();
|
||||
const metadata = await toolkit.buildx.inputs.resolveBuildMetadata();
|
||||
const digest = await toolkit.buildx.inputs.resolveDigest();
|
||||
const imageID = BuildxInputs.resolveBuildImageID();
|
||||
const metadata = BuildxInputs.resolveBuildMetadata();
|
||||
const digest = BuildxInputs.resolveDigest();
|
||||
|
||||
if (imageID) {
|
||||
await core.group(`ImageID`, async () => {
|
||||
|
|
Loading…
Reference in a new issue