mirror of
https://github.com/docker/bake-action.git
synced 2026-01-22 12:22:21 +01:00
Merge pull request #197 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.20.0
chore(deps): Bump @docker/actions-toolkit from 0.19.0 to 0.20.0
This commit is contained in:
@@ -56,7 +56,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
|
||||
};
|
||||
});
|
||||
|
||||
jest.spyOn(Bake.prototype, 'parseDefinitions').mockImplementation(async (): Promise<BakeDefinition> => {
|
||||
jest.spyOn(Bake.prototype, 'getDefinition').mockImplementation(async (): Promise<BakeDefinition> => {
|
||||
return JSON.parse(`{
|
||||
"group": {
|
||||
"default": {
|
||||
@@ -334,7 +334,23 @@ describe('getArgs', () => {
|
||||
return buildxVersion;
|
||||
});
|
||||
const inp = await context.getInputs();
|
||||
const res = await context.getArgs(inp, toolkit);
|
||||
const definition = await toolkit.bake.getDefinition(
|
||||
{
|
||||
files: inp.files,
|
||||
load: inp.load,
|
||||
noCache: inp.noCache,
|
||||
overrides: inp.set,
|
||||
provenance: inp.provenance,
|
||||
push: inp.push,
|
||||
sbom: inp.sbom,
|
||||
source: inp.source,
|
||||
targets: inp.targets
|
||||
},
|
||||
{
|
||||
cwd: inp.workdir
|
||||
}
|
||||
);
|
||||
const res = await context.getArgs(inp, definition, toolkit);
|
||||
expect(res).toEqual(expected);
|
||||
}
|
||||
);
|
||||
|
||||
4
dist/index.js
generated
vendored
4
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@docker/actions-toolkit": "^0.19.0",
|
||||
"@docker/actions-toolkit": "^0.20.0",
|
||||
"handlebars": "^4.7.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {Inputs as BuildxInputs} from '@docker/actions-toolkit/lib/buildx/inputs'
|
||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/bake';
|
||||
|
||||
export interface Inputs {
|
||||
builder: string;
|
||||
@@ -35,29 +36,23 @@ export async function getInputs(): Promise<Inputs> {
|
||||
push: core.getBooleanInput('push'),
|
||||
sbom: core.getInput('sbom'),
|
||||
set: Util.getInputList('set', {ignoreComma: true, quote: false}),
|
||||
source: core.getInput('source')
|
||||
source: getSourceInput('source')
|
||||
};
|
||||
}
|
||||
|
||||
export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||
export async function getArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
||||
// prettier-ignore
|
||||
return [
|
||||
...await getBakeArgs(inputs, toolkit),
|
||||
...await getBakeArgs(inputs, definition, toolkit),
|
||||
...await getCommonArgs(inputs),
|
||||
...inputs.targets
|
||||
];
|
||||
}
|
||||
|
||||
async function getBakeArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||
async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
||||
const args: Array<string> = ['bake'];
|
||||
let source = handlebars.compile(inputs.source)({
|
||||
defaultContext: Context.gitContext()
|
||||
});
|
||||
if (source === '.') {
|
||||
source = '';
|
||||
}
|
||||
if (source) {
|
||||
args.push(source);
|
||||
if (inputs.source) {
|
||||
args.push(inputs.source);
|
||||
}
|
||||
await Util.asyncForEach(inputs.files, async file => {
|
||||
args.push('--file', file);
|
||||
@@ -69,10 +64,9 @@ async function getBakeArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<stri
|
||||
args.push('--metadata-file', BuildxInputs.getBuildMetadataFilePath());
|
||||
}
|
||||
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
|
||||
const bakedef = await toolkit.bake.parseDefinitions([...inputs.files, source], inputs.targets, inputs.set, inputs.load, inputs.push, inputs.workdir);
|
||||
if (inputs.provenance) {
|
||||
args.push('--provenance', inputs.provenance);
|
||||
} else if ((await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(bakedef, inputs.load)) {
|
||||
} else if ((await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(definition, inputs.load)) {
|
||||
// if provenance not specified and BuildKit version compatible for
|
||||
// attestation, set default provenance. Also needs to make sure user
|
||||
// doesn't want to explicitly load the image to docker.
|
||||
@@ -111,3 +105,13 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
function getSourceInput(name: string): string {
|
||||
let source = handlebars.compile(core.getInput(name))({
|
||||
defaultContext: Context.gitContext()
|
||||
});
|
||||
if (source === '.') {
|
||||
source = '';
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
26
src/main.ts
26
src/main.ts
@@ -8,6 +8,7 @@ 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 {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/bake';
|
||||
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker';
|
||||
|
||||
import * as context from './context';
|
||||
@@ -72,7 +73,30 @@ actionsToolkit.run(
|
||||
await toolkit.buildx.printVersion();
|
||||
});
|
||||
|
||||
const args: string[] = await context.getArgs(inputs, toolkit);
|
||||
let definition: BakeDefinition | undefined;
|
||||
await core.group(`Parsing raw definition`, async () => {
|
||||
definition = await toolkit.bake.getDefinition(
|
||||
{
|
||||
files: inputs.files,
|
||||
load: inputs.load,
|
||||
noCache: inputs.noCache,
|
||||
overrides: inputs.set,
|
||||
provenance: inputs.provenance,
|
||||
push: inputs.push,
|
||||
sbom: inputs.sbom,
|
||||
source: inputs.source,
|
||||
targets: inputs.targets
|
||||
},
|
||||
{
|
||||
cwd: inputs.workdir
|
||||
}
|
||||
);
|
||||
});
|
||||
if (!definition) {
|
||||
throw new Error('Bake definition not set');
|
||||
}
|
||||
|
||||
const args: string[] = await context.getArgs(inputs, definition, toolkit);
|
||||
const buildCmd = await toolkit.buildx.getCommand(args);
|
||||
|
||||
await core.group(`Bake definition`, async () => {
|
||||
|
||||
@@ -765,10 +765,10 @@
|
||||
dependencies:
|
||||
"@jridgewell/trace-mapping" "0.3.9"
|
||||
|
||||
"@docker/actions-toolkit@^0.19.0":
|
||||
version "0.19.0"
|
||||
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.19.0.tgz#3b17d06c46d60142423651ddb9d390f65f109a8c"
|
||||
integrity sha512-Es08sgfIBOsEBQLfrJQtfgf5mM9Rl4nfZ7byYQ+umbI7VcUEF4AusyNfqsZob7ZRGu+YUw2jJivZysjVCz6LMg==
|
||||
"@docker/actions-toolkit@^0.20.0":
|
||||
version "0.20.0"
|
||||
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.20.0.tgz#9619ff5da7f282e02e22509a5f2f1d707d4437fe"
|
||||
integrity sha512-oAHSQnWjEyRGmGXePt5A/rZG76U/gddQWF/JmD8lZQOL5WZ7WgfUd2MucOaxq3cd66rMew+iwkfqDzFJQewQQw==
|
||||
dependencies:
|
||||
"@actions/cache" "^3.2.4"
|
||||
"@actions/core" "^1.10.1"
|
||||
|
||||
Reference in New Issue
Block a user