mirror of
https://github.com/docker/bake-action.git
synced 2026-01-22 20:32:21 +01:00
fixes related to actions-toolkit 0.23.0 changes
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -39,6 +39,11 @@ jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean>
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const metadataJson = path.join(tmpDir, 'metadata.json');
|
||||||
|
jest.spyOn(Bake.prototype, 'getMetadataFilePath').mockImplementation((): string => {
|
||||||
|
return metadataJson;
|
||||||
|
});
|
||||||
|
|
||||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||||
return {
|
return {
|
||||||
name: 'builder2',
|
name: 'builder2',
|
||||||
@@ -152,7 +157,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file')
|
'--metadata-file', metadataJson
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -167,7 +172,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
'webapp', 'validate'
|
'webapp', 'validate'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -185,7 +190,7 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--set', '*.cache-from=type=gha',
|
'--set', '*.cache-from=type=gha',
|
||||||
'--set', '*.cache-to=type=gha',
|
'--set', '*.cache-to=type=gha',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file')
|
'--metadata-file', metadataJson
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -199,7 +204,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -215,7 +220,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -231,7 +236,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -247,7 +252,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'false'
|
"--provenance", 'false'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -263,7 +268,7 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'builder-id=foo'
|
"--provenance", 'builder-id=foo'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -282,7 +287,7 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--set', '*.platform=linux/amd64,linux/ppc64le,linux/s390x',
|
'--set', '*.platform=linux/amd64,linux/ppc64le,linux/s390x',
|
||||||
'--set', `*.output=type=image,"name=moby/buildkit:v0.11.0,moby/buildkit:latest",push=true`,
|
'--set', `*.output=type=image,"name=moby/buildkit:v0.11.0,moby/buildkit:latest",push=true`,
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
'image-all'
|
'image-all'
|
||||||
]
|
]
|
||||||
@@ -301,7 +306,7 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--set', `*.labels.foo=bar=#baz`,
|
'--set', `*.labels.foo=bar=#baz`,
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
'image-all'
|
'image-all'
|
||||||
]
|
]
|
||||||
@@ -321,7 +326,7 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/master',
|
'https://github.com/docker/build-push-action.git#refs/heads/master',
|
||||||
'--file', './foo.hcl',
|
'--file', './foo.hcl',
|
||||||
'--metadata-file', path.join(tmpDir, 'metadata-file'),
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -336,7 +341,7 @@ describe('getArgs', () => {
|
|||||||
return buildxVersion;
|
return buildxVersion;
|
||||||
});
|
});
|
||||||
const inp = await context.getInputs();
|
const inp = await context.getInputs();
|
||||||
const definition = await toolkit.bake.getDefinition(
|
const definition = await toolkit.buildxBake.getDefinition(
|
||||||
{
|
{
|
||||||
files: inp.files,
|
files: inp.files,
|
||||||
load: inp.load,
|
load: inp.load,
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
|||||||
args.push('--set', set);
|
args.push('--set', set);
|
||||||
});
|
});
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
|
||||||
args.push('--metadata-file', Bake.getMetadataFilePath());
|
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
|
||||||
}
|
}
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
|
||||||
if (inputs.provenance) {
|
if (inputs.provenance) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import * as path from 'path';
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
|
|
||||||
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake';
|
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context';
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
||||||
@@ -78,7 +77,7 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
let definition: BakeDefinition | undefined;
|
let definition: BakeDefinition | undefined;
|
||||||
await core.group(`Parsing raw definition`, async () => {
|
await core.group(`Parsing raw definition`, async () => {
|
||||||
definition = await toolkit.bake.getDefinition(
|
definition = await toolkit.buildxBake.getDefinition(
|
||||||
{
|
{
|
||||||
files: inputs.files,
|
files: inputs.files,
|
||||||
load: inputs.load,
|
load: inputs.load,
|
||||||
@@ -125,7 +124,7 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadata = Bake.resolveMetadata();
|
const metadata = toolkit.buildxBake.resolveMetadata();
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
await core.group(`Metadata`, async () => {
|
await core.group(`Metadata`, async () => {
|
||||||
const metadatadt = JSON.stringify(metadata, null, 2);
|
const metadatadt = JSON.stringify(metadata, null, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user