mirror of
https://github.com/docker/metadata-action.git
synced 2026-01-15 00:43:08 +08:00
Add DOCKER_METADATA_SET_OUTPUT_ENV
Signed-off-by: Curtis Vogt <curtis.vogt@gmail.com>
This commit is contained in:
parent
1556862073
commit
9a3121552c
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -474,6 +474,8 @@ jobs:
|
|||||||
|
|
||||||
no-output-env:
|
no-output-env:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOCKER_METADATA_SET_OUTPUT_ENV: false
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -490,7 +492,6 @@ jobs:
|
|||||||
maintainer=CrazyMax
|
maintainer=CrazyMax
|
||||||
annotations: |
|
annotations: |
|
||||||
maintainer=Foo
|
maintainer=Foo
|
||||||
output-env: false
|
|
||||||
-
|
-
|
||||||
name: No output environment variables set
|
name: No output environment variables set
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@ -303,7 +303,6 @@ The following inputs can be used as `step.with` keys:
|
|||||||
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
||||||
| `sep-annotations` | String | Separator to use for annotations output (default `\n`) |
|
| `sep-annotations` | String | Separator to use for annotations output (default `\n`) |
|
||||||
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
|
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
|
||||||
| `output-env` | Bool | If `true`, sets each output as an environmental variable (default `true`) |
|
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
@ -320,7 +319,7 @@ The following outputs are available:
|
|||||||
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
|
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
|
||||||
| `bake-file-annotations` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with [annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
|
| `bake-file-annotations` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with [annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
|
||||||
|
|
||||||
Alternatively, each output is also exported as an environment variable when `output-env` is `true`:
|
Alternatively, each output is also exported as an environment variable when `DOCKER_METADATA_SET_OUTPUT_ENV` is `true`:
|
||||||
|
|
||||||
* `DOCKER_METADATA_OUTPUT_VERSION`
|
* `DOCKER_METADATA_OUTPUT_VERSION`
|
||||||
* `DOCKER_METADATA_OUTPUT_TAGS`
|
* `DOCKER_METADATA_OUTPUT_TAGS`
|
||||||
@ -347,6 +346,7 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
|
|||||||
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
|
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
|
||||||
| `DOCKER_METADATA_SHORT_SHA_LENGTH` | Number | Specifies the length of the [short commit SHA](#typesha) to ensure uniqueness. Default is `7`, but can be increased for larger repositories. |
|
| `DOCKER_METADATA_SHORT_SHA_LENGTH` | Number | Specifies the length of the [short commit SHA](#typesha) to ensure uniqueness. Default is `7`, but can be increased for larger repositories. |
|
||||||
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
|
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
|
||||||
|
| `DOCKER_METADATA_SET_OUTPUT_ENV` | Bool | If `true`, sets each output as an environmental variable (default `true`) |
|
||||||
|
|
||||||
## `context` input
|
## `context` input
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,6 @@ describe('getInputs', () => {
|
|||||||
sepTags: '\n',
|
sepTags: '\n',
|
||||||
sepAnnotations: '\n',
|
sepAnnotations: '\n',
|
||||||
tags: [],
|
tags: [],
|
||||||
outputEnv: true,
|
|
||||||
} as Inputs
|
} as Inputs
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -71,7 +70,6 @@ describe('getInputs', () => {
|
|||||||
sepTags: ',',
|
sepTags: ',',
|
||||||
sepAnnotations: ',',
|
sepAnnotations: ',',
|
||||||
tags: [],
|
tags: [],
|
||||||
outputEnv: true,
|
|
||||||
} as Inputs
|
} as Inputs
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -91,7 +89,6 @@ describe('getInputs', () => {
|
|||||||
sepTags: '\n',
|
sepTags: '\n',
|
||||||
sepAnnotations: '\n',
|
sepAnnotations: '\n',
|
||||||
tags: [],
|
tags: [],
|
||||||
outputEnv: true,
|
|
||||||
} as Inputs
|
} as Inputs
|
||||||
],
|
],
|
||||||
])(
|
])(
|
||||||
|
|||||||
@ -38,10 +38,6 @@ inputs:
|
|||||||
bake-target:
|
bake-target:
|
||||||
description: 'Bake target name (default docker-metadata-action)'
|
description: 'Bake target name (default docker-metadata-action)'
|
||||||
required: false
|
required: false
|
||||||
output-env:
|
|
||||||
description:
|
|
||||||
default: 'true'
|
|
||||||
required: true
|
|
||||||
github-token:
|
github-token:
|
||||||
description: 'GitHub Token as provided by secrets'
|
description: 'GitHub Token as provided by secrets'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
|||||||
@ -20,7 +20,6 @@ export interface Inputs {
|
|||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
sepAnnotations: string;
|
sepAnnotations: string;
|
||||||
bakeTarget: string;
|
bakeTarget: string;
|
||||||
outputEnv: boolean;
|
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ export function getInputs(): Inputs {
|
|||||||
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
|
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
|
||||||
sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,
|
sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,
|
||||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
||||||
outputEnv: (core.getInput('output-env') || 'true') === 'true',
|
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,8 @@ actionsToolkit.run(
|
|||||||
const toolkit = new Toolkit({githubToken: inputs.githubToken});
|
const toolkit = new Toolkit({githubToken: inputs.githubToken});
|
||||||
const context = await getContext(inputs.context, toolkit);
|
const context = await getContext(inputs.context, toolkit);
|
||||||
const repo = await toolkit.github.repoData();
|
const repo = await toolkit.github.repoData();
|
||||||
const setOutput = inputs.outputEnv ? setOutputAndEnv : core.setOutput;
|
const outputEnv = (process.env.DOCKER_METADATA_SET_OUTPUT_ENV || 'true') === 'true'
|
||||||
|
const setOutput = outputEnv ? setOutputAndEnv : core.setOutput;
|
||||||
|
|
||||||
await core.group(`Context info`, async () => {
|
await core.group(`Context info`, async () => {
|
||||||
core.info(`eventName: ${context.eventName}`);
|
core.info(`eventName: ${context.eventName}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user