mirror of
https://github.com/docker/build-push-action.git
synced 2026-02-21 17:06:39 +00:00
Add parameters for controlling inheritance of labels and annotations
Add new parameters `inherit-annotations` and `inherit-labels` that allows disabling inheritance from the base image or base states. Signed-off-by: Sebastian Schimpfhauser <seschi98@googlemail.com>
This commit is contained in:
parent
64c9b14150
commit
7dcf1e826a
@ -224,7 +224,7 @@ The following inputs can be used as `step.with` keys:
|
||||
> ```
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|-----------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `add-hosts` | List/CSV | List of [customs host-to-IP mapping](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) (e.g., `docker:10.180.0.1`) |
|
||||
| `allow` | List/CSV | List of [extra privileged entitlement](https://docs.docker.com/engine/reference/commandline/buildx_build/#allow) (e.g., `network.host,security.insecure`) |
|
||||
| `annotations` | List | List of annotation to set to the image |
|
||||
@ -238,6 +238,8 @@ The following inputs can be used as `step.with` keys:
|
||||
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
||||
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
||||
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
||||
| `inherit-annotations` | Bool | Inherit the annotations from the base image or base stages. (default `true`) |
|
||||
| `inherit-labels` | Bool | Inherit the labels from the base image or base stages. (default `true`) |
|
||||
| `labels` | List | List of metadata for an image |
|
||||
| `load` | Bool | [Load](https://docs.docker.com/engine/reference/commandline/buildx_build/#load) is a shorthand for `--output=type=docker` (default `false`) |
|
||||
| `network` | String | Set the networking mode for the `RUN` instructions during build |
|
||||
|
||||
@ -88,6 +88,8 @@ describe('getArgs', () => {
|
||||
'0.4.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -109,6 +111,8 @@ ARG=val
|
||||
"MULTILINE=aaaa
|
||||
bbbb
|
||||
ccc"`],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -128,6 +132,8 @@ ccc"`],
|
||||
2,
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tags', 'name/app:7.4, name/app:latest'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
@ -148,6 +154,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'],
|
||||
['outputs', 'type=local,dest=./release-out'],
|
||||
['load', 'false'],
|
||||
@ -169,6 +177,8 @@ ccc"`],
|
||||
'0.4.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['platforms', 'linux/amd64,linux/arm64'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
@ -187,6 +197,8 @@ ccc"`],
|
||||
'0.4.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -204,6 +216,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
@ -223,6 +237,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['github-token', 'abcdefghijklmno0123456789'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['outputs', '.'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
@ -242,6 +258,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tag', 'localhost:5000/name/app:latest'],
|
||||
['platforms', 'linux/amd64,linux/arm64'],
|
||||
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
|
||||
@ -269,6 +287,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tag', 'localhost:5000/name/app:latest'],
|
||||
['platforms', 'linux/amd64,linux/arm64'],
|
||||
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
|
||||
@ -307,6 +327,8 @@ ccc"`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tag', 'localhost:5000/name/app:latest'],
|
||||
['platforms', 'linux/amd64,linux/arm64'],
|
||||
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
|
||||
@ -345,6 +367,8 @@ ccc`],
|
||||
'0.5.1',
|
||||
new Map<string, string>([
|
||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tag', 'localhost:5000/name/app:latest'],
|
||||
['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt')}`],
|
||||
['file', './test/Dockerfile'],
|
||||
@ -372,6 +396,8 @@ ccc`],
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'],
|
||||
['outputs', 'type=local,dest=./release-out'],
|
||||
['load', 'false'],
|
||||
@ -393,6 +419,8 @@ ccc`],
|
||||
'0.6.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['tag', 'localhost:5000/name/app:latest'],
|
||||
['file', './test/Dockerfile'],
|
||||
['add-hosts', 'docker:10.180.0.1,foo:10.0.0.1'],
|
||||
@ -420,6 +448,8 @@ ccc`],
|
||||
'0.7.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['file', './test/Dockerfile'],
|
||||
['add-hosts', 'docker:10.180.0.1\nfoo:10.0.0.1'],
|
||||
['cgroup-parent', 'foo'],
|
||||
@ -451,6 +481,8 @@ nproc=3`],
|
||||
'0.7.0',
|
||||
new Map<string, string>([
|
||||
['context', '{{defaultContext}}:docker'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -470,6 +502,8 @@ nproc=3`],
|
||||
new Map<string, string>([
|
||||
['github-token', 'abcdefghijklmno0123456789'],
|
||||
['context', '{{defaultContext}}:subdir'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -489,6 +523,8 @@ nproc=3`],
|
||||
'0.8.2',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -508,6 +544,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -527,6 +565,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -547,6 +587,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -567,6 +609,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -587,6 +631,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -607,6 +653,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -627,6 +675,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'true'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -646,6 +696,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['build-args', `FOO=bar#baz`],
|
||||
['load', 'true'],
|
||||
['no-cache', 'false'],
|
||||
@ -667,6 +719,8 @@ nproc=3`],
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['no-cache', 'false'],
|
||||
['load', 'true'],
|
||||
['push', 'false'],
|
||||
@ -690,6 +744,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.10.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['no-cache', 'false'],
|
||||
['load', 'true'],
|
||||
['push', 'false'],
|
||||
@ -712,6 +768,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.11.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['annotations', 'example1=www\nindex:example2=xxx\nmanifest:example3=yyy\nmanifest-descriptor[linux/amd64]:example4=zzz'],
|
||||
['outputs', 'type=local,dest=./release-out'],
|
||||
['load', 'false'],
|
||||
@ -733,6 +791,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.12.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['annotations', 'example1=www\nindex:example2=xxx\nmanifest:example3=yyy\nmanifest-descriptor[linux/amd64]:example4=zzz'],
|
||||
['outputs', 'type=local,dest=./release-out'],
|
||||
['load', 'false'],
|
||||
@ -758,6 +818,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.12.0',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['outputs', `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
@ -779,6 +841,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.13.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -801,6 +865,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.13.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -822,6 +888,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.13.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -842,6 +910,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
'0.13.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'true'],
|
||||
['inherit-labels', 'true'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
@ -857,6 +927,30 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
||||
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
|
||||
])
|
||||
],
|
||||
[
|
||||
35,
|
||||
'0.13.1',
|
||||
new Map<string, string>([
|
||||
['context', '.'],
|
||||
['inherit-annotations', 'false'],
|
||||
['inherit-labels', 'false'],
|
||||
['load', 'false'],
|
||||
['no-cache', 'false'],
|
||||
['push', 'false'],
|
||||
['pull', 'false']
|
||||
]),
|
||||
[
|
||||
'build',
|
||||
'--iidfile', imageIDFilePath,
|
||||
'--inherit-annotations', 'false',
|
||||
'--inherit-labels', 'false',
|
||||
'--metadata-file', metadataJson,
|
||||
'.'
|
||||
],
|
||||
new Map<string, string>([
|
||||
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
|
||||
])
|
||||
],
|
||||
])(
|
||||
'[%d] given %p with %p as inputs, returns %p',
|
||||
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
|
||||
|
||||
@ -46,6 +46,14 @@ inputs:
|
||||
file:
|
||||
description: "Path to the Dockerfile"
|
||||
required: false
|
||||
inherit-annotations:
|
||||
description: "Inherit the annotations from the base image or base stages"
|
||||
required: false
|
||||
default: 'true'
|
||||
inherit-labels:
|
||||
description: "Inherit the labels from the base image or base stages"
|
||||
required: false
|
||||
default: 'true'
|
||||
labels:
|
||||
description: "List of metadata for an image"
|
||||
required: false
|
||||
|
||||
2
dist/index.js
generated
vendored
2
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
@ -21,6 +21,8 @@ export interface Inputs {
|
||||
'cgroup-parent': string;
|
||||
context: string;
|
||||
file: string;
|
||||
'inherit-annotations': boolean;
|
||||
'inherit-labels': boolean;
|
||||
labels: string[];
|
||||
load: boolean;
|
||||
network: string;
|
||||
@ -58,6 +60,8 @@ export async function getInputs(): Promise<Inputs> {
|
||||
'cgroup-parent': core.getInput('cgroup-parent'),
|
||||
context: core.getInput('context') || Context.gitContext(),
|
||||
file: core.getInput('file'),
|
||||
'inherit-annotations': core.getBooleanInput('inherit-annotations'),
|
||||
'inherit-labels': core.getBooleanInput('inherit-labels'),
|
||||
labels: Util.getInputList('labels', {ignoreComma: true}),
|
||||
load: core.getBooleanInput('load'),
|
||||
network: core.getInput('network'),
|
||||
@ -151,6 +155,12 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
||||
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());
|
||||
}
|
||||
if (!inputs['inherit-annotations']) {
|
||||
args.push('--inherit-annotations', 'false');
|
||||
}
|
||||
if (!inputs['inherit-labels']) {
|
||||
args.push('--inherit-labels', 'false');
|
||||
}
|
||||
await Util.asyncForEach(inputs.labels, async label => {
|
||||
args.push('--label', label);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user