Merge pull request #352 from crazy-max/annotations-alt

annotations support
This commit is contained in:
CrazyMax authored and GitHub committed 2023-11-30 01:10:44 -08:00
commit f33ad1e20d
8 files changed
+446 -49

No files matched your search

+44
View File
@@ -383,3 +383,47 @@ jobs:
DOCKER_METADATA_OUTPUT_TAGS
DOCKER_METADATA_OUTPUT_LABELS
DOCKER_METADATA_OUTPUT_JSON
bake-annotations:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: docker_meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.0-rc1
-
name: Build
uses: docker/bake-action@v4
with:
files: |
./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-annotations }}
targets: |
release
+81 -11
View File
@@ -48,6 +48,7 @@ ___
* [Major version zero](#major-version-zero)
* [JSON output object](#json-output-object)
* [Overwrite labels](#overwrite-labels)
* [Annotations](#annotations)
* [Contributing](#contributing)
## Usage
@@ -307,23 +308,27 @@ The following inputs can be used as `step.with` keys:
The following outputs are available:
| Name | Type | Description |
|--------------------|--------|-------------------------------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `json` | String | JSON output of tags and labels |
| `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
| Name | Type | Description |
|-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
| `json` | String | JSON output of tags and labels |
| `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
| `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) |
Alternatively, each output is also exported as an environment variable:
* `DOCKER_METADATA_OUTPUT_VERSION`
* `DOCKER_METADATA_OUTPUT_TAGS`
* `DOCKER_METADATA_OUTPUT_LABELS`
* `DOCKER_METADATA_OUTPUT_ANNOTATIONS`
* `DOCKER_METADATA_OUTPUT_JSON`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_ANNOTATIONS`
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/):
@@ -336,9 +341,10 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
### environment variables
| Name | Type | Description |
|-------------------------------|------|------------------------------------------------------------------------------------------------------------|
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
| Name | Type | Description |
|--------------------------------------|--------|------------------------------------------------------------------------------------------------------------|
| `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_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
## `context` input
@@ -904,6 +910,70 @@ labels generated are not suitable, you can overwrite them like this:
org.opencontainers.image.vendor=MyCompany
```
### Annotations
Since Buildx 0.12, it is possible to set annotations to your image through the
`--annotation` flag.
With the [`build-push-action`](https://github.com/docker/build-push-action/),
you can set the `annotations` input with the value of the `annotations` output
of the `metadata-action`:
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
-
name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
```
The same can be done with the [`bake-action`](https://github.com/docker/bake-action/):
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
-
name: Build
uses: docker/bake-action@v3
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-annotations }}
targets: build
```
If you want to set specific level(s) for your annotations, you can use the
[`DOCKER_METADATA_ANNOTATIONS_LEVELS` environment variable](#environment-variables)
with a comma separated list of levels (defaults to `manifest`):
```yaml
-
name: Docker meta
uses: docker/metadata-action@v5
with:
images: name/app
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
```
More information about annotations in the [BuildKit documentation](https://github.com/moby/buildkit/blob/master/docs/annotations.md).
## Contributing
Want to contribute? Awesome! You can find information about contributing to
+257 -9
View File
@@ -3503,7 +3503,18 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "dev"
}
},
"annotations": [
"manifest:foo=",
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=dev"
]
}
],
[
@@ -3530,7 +3541,17 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "dev"
}
},
"annotations": [
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=dev"
]
}
],
[
@@ -3563,7 +3584,17 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "release1"
}
},
"annotations": [
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=release1"
]
}
],
[
@@ -3597,7 +3628,17 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "20200110"
}
},
"annotations": [
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=20200110"
]
}
],
[
@@ -3640,7 +3681,17 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "1.1.1"
}
},
"annotations": [
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=1.1.1"
]
}
],
[
@@ -3672,7 +3723,17 @@ describe('json', () => {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "my"
}
},
"annotations": [
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=This your first repo!",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=Hello-World",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.version=my"
]
}
],
[
@@ -3704,7 +3765,19 @@ describe('json', () => {
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.vendor": "MyCompany",
"org.opencontainers.image.version": "v1.1.1"
}
},
"annotations": [
"manifest:maintainer=CrazyMax",
"manifest:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest:org.opencontainers.image.description=Another description",
"manifest:org.opencontainers.image.licenses=MIT",
"manifest:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.title=MyCustom=Title",
"manifest:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest:org.opencontainers.image.vendor=MyCompany",
"manifest:org.opencontainers.image.version=v1.1.1"
]
}
]
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exJSON: unknown) => {
@@ -3714,7 +3787,7 @@ describe('json', () => {
const repo = await toolkit.github.repoData();
const meta = new Meta({...getInputs(), ...inputs}, await getContext(ContextSource.workflow), repo);
const jsonOutput = meta.getJSON();
const jsonOutput = meta.getJSON(['manifest']);
expect(jsonOutput).toEqual(exJSON);
});
});
@@ -3769,6 +3842,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=dev",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=dev"
]
}
}
}
],
[
@@ -3810,6 +3907,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=dev",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=dev"
]
}
}
}
],
[
@@ -3857,6 +3978,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"meta": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=release1",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=release1"
]
}
}
}
],
[
@@ -3905,6 +4050,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=20200110",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=20200110"
]
}
}
}
],
[
@@ -3962,6 +4131,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=1.1.1",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=1.1.1"
]
}
}
}
],
[
@@ -4008,6 +4201,30 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=This your first repo!",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=Hello-World",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.version=my",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=This your first repo!",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=Hello-World",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.version=my"
]
}
}
}
],
[
@@ -4053,9 +4270,37 @@ describe('bakeFile', () => {
}
}
}
},
{
"target": {
"docker-metadata-action": {
"annotations": [
"index:maintainer=CrazyMax",
"index:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"index:org.opencontainers.image.description=Another description",
"index:org.opencontainers.image.licenses=MIT",
"index:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"index:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.title=MyCustom=Title",
"index:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"index:org.opencontainers.image.vendor=MyCompany",
"index:org.opencontainers.image.version=v1.1.1",
"manifest-descriptor:maintainer=CrazyMax",
"manifest-descriptor:org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"manifest-descriptor:org.opencontainers.image.description=Another description",
"manifest-descriptor:org.opencontainers.image.licenses=MIT",
"manifest-descriptor:org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"manifest-descriptor:org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.title=MyCustom=Title",
"manifest-descriptor:org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"manifest-descriptor:org.opencontainers.image.vendor=MyCompany",
"manifest-descriptor:org.opencontainers.image.version=v1.1.1"
]
}
}
}
]
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exBakeTags: unknown, exBakeLabels: unknown) => {
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exBakeTags: unknown, exBakeLabels: unknown, exBakeAnnotations: unknown) => {
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
const toolkit = new Toolkit();
@@ -4067,6 +4312,9 @@ describe('bakeFile', () => {
const bakeFileLabels = meta.getBakeFile('labels');
expect(JSON.parse(fs.readFileSync(bakeFileLabels, 'utf8'))).toEqual(exBakeLabels);
const bakeFileAnnotations = meta.getBakeFile('annotations:index,manifest-descriptor');
expect(JSON.parse(fs.readFileSync(bakeFileAnnotations, 'utf8'))).toEqual(exBakeAnnotations);
});
});
+4
View File
@@ -44,12 +44,16 @@ outputs:
description: 'Generated Docker tags'
labels:
description: 'Generated Docker labels'
annotations:
description: 'Generated annotations'
json:
description: 'JSON output of tags and labels'
bake-file-tags:
description: 'Bake definition file with tags'
bake-file-labels:
description: 'Bake definition file with labels'
bake-file-annotations:
description: 'Bake definiton file with annotations'
bake-file:
description: 'Bake definition file with tags and labels'
Generated Vendored
+1 -1
View File
@@ -86,5 +86,5 @@ const p=i(57147);const c=i(22037);const d=i(71017);const A=i(6113);const l={fs:p
* XRegExp 4.4.1
* <xregexp.com>
* Steven Levithan (c) 2007-present MIT License
*/var B="xregexp";var v={astral:false,namespacing:false};var R={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split};var I={};var N={};var W={};var w=[];var S="default";var Q="class";var x={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/};var L=/\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g;var T=R.exec.call(/()??/,"")[1]===undefined;var _=(0,C["default"])(/x/)!==undefined;var D={},k=D.toString;function hasNativeFlag(r){var a=true;try{new RegExp("",r);if(r==="y"){var i=function(){return"gy"}();var p=".a".replace(new RegExp("a",i),".")==="..";if(p){a=false}}}catch(r){a=false}return a}var P=hasNativeFlag("u");var U=hasNativeFlag("y");var X={g:true,i:true,m:true,u:P,y:U};function augment(r,a,i,p,c){var d;r[B]={captureNames:a};if(c){return r}if(r.__proto__){r.__proto__=XRegExp.prototype}else{for(var A in XRegExp.prototype){r[A]=XRegExp.prototype[A]}}r[B].source=i;r[B].flags=p?(0,y["default"])(d=p.split("")).call(d).join(""):p;return r}function clipDuplicates(r){return R.replace.call(r,/([\s\S])(?=[\s\S]*\1)/g,"")}function copyRegex(r,a){var i;if(!XRegExp.isRegExp(r)){throw new TypeError("Type RegExp expected")}var p=r[B]||{};var c=getNativeFlags(r);var d="";var A="";var l=null;var u=null;a=a||{};if(a.removeG){A+="g"}if(a.removeY){A+="y"}if(A){c=R.replace.call(c,new RegExp("[".concat(A,"]+"),"g"),"")}if(a.addG){d+="g"}if(a.addY){d+="y"}if(d){c=clipDuplicates(c+d)}if(!a.isInternalOnly){if(p.source!==undefined){l=p.source}if((0,C["default"])(p)!=null){u=d?clipDuplicates((0,C["default"])(p)+d):(0,C["default"])(p)}}r=augment(new RegExp(a.source||r.source,c),hasNamedCapture(r)?(0,q["default"])(i=p.captureNames).call(i,0):null,l,u,a.isInternalOnly);return r}function dec(r){return(0,E["default"])(r,16)}function getContextualTokenSeparator(r,a,i){if(r.input[r.index-1]==="("||r.input[r.index+r[0].length]===")"||r.input[r.index-1]==="|"||r.input[r.index+r[0].length]==="|"||r.index<1||r.index+r[0].length>=r.input.length||R.test.call(/^\(\?[:=!]/,r.input.substr(r.index-3,3))||isQuantifierNext(r.input,r.index+r[0].length,i)){return""}return"(?:)"}function getNativeFlags(r){return _?(0,C["default"])(r):R.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(r))[1]}function hasNamedCapture(r){return!!(r[B]&&r[B].captureNames)}function hex(r){return(0,E["default"])(r,10).toString(16)}function isQuantifierNext(r,a,i){var p="\\(\\?#[^)]*\\)";var c="#[^#\\n]*";var d="[?*+]|{\\d+(?:,\\d*)?}";return R.test.call((0,g["default"])(i).call(i,"x")?/^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/:/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/,(0,q["default"])(r).call(r,a))}function isType(r,a){return k.call(r)==="[object ".concat(a,"]")}function pad4(r){while(r.length<4){r="0".concat(r)}return r}function prepareFlags(r,a){if(clipDuplicates(a)!==a){throw new SyntaxError("Invalid duplicate regex flag ".concat(a))}r=R.replace.call(r,/^\(\?([\w$]+)\)/,(function(r,i){if(R.test.call(/[gy]/,i)){throw new SyntaxError("Cannot use flag g or y in mode modifier ".concat(r))}a=clipDuplicates(a+i);return""}));var i=_createForOfIteratorHelper(a),p;try{for(i.s();!(p=i.n()).done;){var c=p.value;if(!X[c]){throw new SyntaxError("Unknown regex flag ".concat(c))}}}catch(r){i.e(r)}finally{i.f()}return{pattern:r,flags:a}}function prepareOptions(r){var a={};if(isType(r,"String")){(0,h["default"])(XRegExp).call(XRegExp,r,/[^\s,]+/,(function(r){a[r]=true}));return a}return r}function registerFlag(r){if(!/^[\w$]$/.test(r)){throw new Error("Flag must be a single character A-Za-z0-9_$")}X[r]=true}function runTokens(r,a,i,p,c){var d=w.length;var A=r[i];var l=null;var u;var b;while(d--){b=w[d];if(b.leadChar&&b.leadChar!==A||b.scope!==p&&b.scope!=="all"||b.flag&&!(0,g["default"])(a).call(a,b.flag)){continue}u=XRegExp.exec(r,b.regex,i,"sticky");if(u){l={matchLength:u[0].length,output:b.handler.call(c,u,p,a),reparse:b.reparse};break}}return l}function setAstral(r){v.astral=r}function setNamespacing(r){v.namespacing=r}function toObject(r){if(r==null){throw new TypeError("Cannot convert null or undefined to object")}return r}function XRegExp(r,a){if(XRegExp.isRegExp(r)){if(a!==undefined){throw new TypeError("Cannot supply flags when copying a RegExp")}return copyRegex(r)}r=r===undefined?"":String(r);a=a===undefined?"":String(a);if(XRegExp.isInstalled("astral")&&!(0,g["default"])(a).call(a,"A")){a+="A"}if(!W[r]){W[r]={}}if(!W[r][a]){var i={hasNamedCapture:false,captureNames:[]};var p=S;var c="";var d=0;var A;var l=prepareFlags(r,a);var u=l.pattern;var b=(0,C["default"])(l);while(d<u.length){do{A=runTokens(u,b,d,p,i);if(A&&A.reparse){u=(0,q["default"])(u).call(u,0,d)+A.output+(0,q["default"])(u).call(u,d+A.matchLength)}}while(A&&A.reparsLine truncated
*/var B="xregexp";var v={astral:false,namespacing:false};var R={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split};var I={};var N={};var W={};var w=[];var S="default";var Q="class";var x={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/};var L=/\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g;var T=R.exec.call(/()??/,"")[1]===undefined;var _=(0,C["default"])(/x/)!==undefined;var D={},k=D.toString;function hasNativeFlag(r){var a=true;try{new RegExp("",r);if(r==="y"){var i=function(){return"gy"}();var p=".a".replace(new RegExp("a",i),".")==="..";if(p){a=false}}}catch(r){a=false}return a}var P=hasNativeFlag("u");var U=hasNativeFlag("y");var X={g:true,i:true,m:true,u:P,y:U};function augment(r,a,i,p,c){var d;r[B]={captureNames:a};if(c){return r}if(r.__proto__){r.__proto__=XRegExp.prototype}else{for(var A in XRegExp.prototype){r[A]=XRegExp.prototype[A]}}r[B].source=i;r[B].flags=p?(0,y["default"])(d=p.split("")).call(d).join(""):p;return r}function clipDuplicates(r){return R.replace.call(r,/([\s\S])(?=[\s\S]*\1)/g,"")}function copyRegex(r,a){var i;if(!XRegExp.isRegExp(r)){throw new TypeError("Type RegExp expected")}var p=r[B]||{};var c=getNativeFlags(r);var d="";var A="";var l=null;var u=null;a=a||{};if(a.removeG){A+="g"}if(a.removeY){A+="y"}if(A){c=R.replace.call(c,new RegExp("[".concat(A,"]+"),"g"),"")}if(a.addG){d+="g"}if(a.addY){d+="y"}if(d){c=clipDuplicates(c+d)}if(!a.isInternalOnly){if(p.source!==undefined){l=p.source}if((0,C["default"])(p)!=null){u=d?clipDuplicates((0,C["default"])(p)+d):(0,C["default"])(p)}}r=augment(new RegExp(a.source||r.source,c),hasNamedCapture(r)?(0,q["default"])(i=p.captureNames).call(i,0):null,l,u,a.isInternalOnly);return r}function dec(r){return(0,E["default"])(r,16)}function getContextualTokenSeparator(r,a,i){if(r.input[r.index-1]==="("||r.input[r.index+r[0].length]===")"||r.input[r.index-1]==="|"||r.input[r.index+r[0].length]==="|"||r.index<1||r.index+r[0].length>=r.input.length||R.test.call(/^\(\?[:=!]/,r.input.substr(r.index-3,3))||isQuantifierNext(r.input,r.index+r[0].length,i)){return""}return"(?:)"}function getNativeFlags(r){return _?(0,C["default"])(r):R.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(r))[1]}function hasNamedCapture(r){return!!(r[B]&&r[B].captureNames)}function hex(r){return(0,E["default"])(r,10).toString(16)}function isQuantifierNext(r,a,i){var p="\\(\\?#[^)]*\\)";var c="#[^#\\n]*";var d="[?*+]|{\\d+(?:,\\d*)?}";return R.test.call((0,g["default"])(i).call(i,"x")?/^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/:/^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/,(0,q["default"])(r).call(r,a))}function isType(r,a){return k.call(r)==="[object ".concat(a,"]")}function pad4(r){while(r.length<4){r="0".concat(r)}return r}function prepareFlags(r,a){if(clipDuplicates(a)!==a){throw new SyntaxError("Invalid duplicate regex flag ".concat(a))}r=R.replace.call(r,/^\(\?([\w$]+)\)/,(function(r,i){if(R.test.call(/[gy]/,i)){throw new SyntaxError("Cannot use flag g or y in mode modifier ".concat(r))}a=clipDuplicates(a+i);return""}));var i=_createForOfIteratorHelper(a),p;try{for(i.s();!(p=i.n()).done;){var c=p.value;if(!X[c]){throw new SyntaxError("Unknown regex flag ".concat(c))}}}catch(r){i.e(r)}finally{i.f()}return{pattern:r,flags:a}}function prepareOptions(r){var a={};if(isType(r,"String")){(0,h["default"])(XRegExp).call(XRegExp,r,/[^\s,]+/,(function(r){a[r]=true}));return a}return r}function registerFlag(r){if(!/^[\w$]$/.test(r)){throw new Error("Flag must be a single character A-Za-z0-9_$")}X[r]=true}function runTokens(r,a,i,p,c){var d=w.length;var A=r[i];var l=null;var u;var b;while(d--){b=w[d];if(b.leadChar&&b.leadChar!==A||b.scope!==p&&b.scope!=="all"||b.flag&&!(0,g["default"])(a).call(a,b.flag)){continue}u=XRegExp.exec(r,b.regex,i,"sticky");if(u){l={matchLength:u[0].length,output:b.handler.call(c,u,p,a),reparse:b.reparse};break}}return l}function setAstral(r){v.astral=r}function setNamespacing(r){v.namespacing=r}function toObject(r){if(r==null){throw new TypeError("Cannot convert null or undefined to object")}return r}function XRegExp(r,a){if(XRegExp.isRegExp(r)){if(a!==undefined){throw new TypeError("Cannot supply flags when copying a RegExp")}return copyRegex(r)}r=r===undefined?"":String(r);a=a===undefined?"":String(a);if(XRegExp.isInstalled("astral")&&!(0,g["default"])(a).call(a,"A")){a+="A"}if(!W[r]){W[r]={}}if(!W[r][a]){var i={hasNamedCapture:false,captureNames:[]};var p=S;var c="";var d=0;var A;var l=prepareFlags(r,a);var u=l.pattern;var b=(0,C["default"])(l);while(d<u.length){do{A=runTokens(u,b,d,p,i);if(A&&A.reparse){u=(0,q["default"])(u).call(u,0,d)+A.output+(0,q["default"])(u).call(u,d+A.matchLength)}}while(A&&A.reparsLine truncated
//# sourceMappingURL=index.js.map
Generated Vendored
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__setModuleDefault","v","value","__importStar","mod","result","prototype","hasOwnProperty","call","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","exports","saveCache","restoreCache","isFeatureAvailable","ReserveCacheError","ValidationError","core","__webpack_require__","path","utils","cacheHttpClient","tar_1","Error","constructor","message","super","name","setPrototypeOf","checkPaths","paths","length","checkKey","key","regex","test","process","env","primaryKey","restoreKeys","options","enableCrossOsArchive","keys","debug","JSON","stringify","compressionMethod","getCompressionMethod","archivePath","cacheEntry","getCacheEntry","archiveLocation","lookupOnly","info","cacheKey","join","createTempDirectory","getCacheFileName","downloadCache","isDebug","listTar","archiveFileSize","getArchiveFileSizeInBytes","Math","round","extractTar","error","typedError","warning","unlinkFile","_a","_b","_c","_d","_e","cacheId","cachePaths","resolvePaths","archiveFolder","createTar","fileSizeLimit","isGhes","reserveCacheResponse","reserveCache","cacheSize","statusCode","getCacheVersion","http_client_1","auth_1","crypto","fs","url_1","downloadUtils_1","options_1","requestUtils_1","versionSalt","getCacheApiUrl","resource","baseUrl","url","createAcceptHeader","type","apiVersion","getRequestOptions","requestOptions","headers","Accept","createHttpClient","token","bearerCredentialHandler","BearerCredentialHandler","HttpClient","components","push","platform","createHash","update","digest","httpClient","version","encodeURIComponent","response","retryTypedResponse","getJson","printCachesListForDiagnostics","isSuccessStatusCode","cacheResult","cacheDownloadUrl","setSecret","cacheListResult","totalCount","artifactCaches","cacheVersion","scope","creationTime","archiveUrl","URL","downloadOptions","getDownloadOptions","hostname","endsWith","useAzureSdk","downloadCacheStorageSDK","concurrentBlobDownloads","downloadCacheHttpClientConcurrent","downloadCacheHttpClient","reserveCacheRequest","postJson","getContentRange","start","end","uploadChunk","resourceUrl","openStream","additionalHeaders","uploadChunkResponse","retryHttpClientResponse","sendStream","uploadFile","fileSize","toString","fd","openSync","uploadOptions","getUploadOptions","concurrency","assertDefined","uploadConcurrency","maxChunkSize","uploadChunkSize","parallelUploads","Array","offset","all","map","chunkSize","min","createReadStream","autoClose","on","closeSync","commitCache","filesize","commitCacheRequest","size","commitCacheResponse","__asyncValues","Symbol","asyncIterator","TypeError","i","__values","iterator","verb","n","settle","d","getGnuTarPathOnWindows","exec","glob","io","semver","util","uuid_1","constants_1","IS_WINDOWS","tempDirectory","baseLocation","dest","v4","mkdirP","filePath","statSync","patterns","e_1","workspace","cwd","globber","implicitDescendants","_f","globGenerator","_g","file","relativeFile","relative","replace","RegExp","sep","e_1_1","return","promisify","unlink","getVersion","app","additionalArgs","versionOutput","ignoreReturnCode","silent","listeners","stdout","data","stderr","err","trim","clean","CompressionMethod","Gzip","ZstdWithoutLong","CacheFilename","Zstd","existsSync","GnuTarPathOnWindows","toLowerCase","includes","which","ghUrl","toUpperCase","ManifestFilename","TarFilename","SystemTarPathOnWindows","SocketTimeout","DefaultRetryDelay","DefaultRetryAttempts","ArchiveToolType","DownloadProgress","storage_blob_1","buffer","stream","abort_controller_1","pipeResponseToStream","output","pipeline","contentLength","segmentIndex","segmentSize","segmentOffset","receivedBytes","displayedComplete","startTime","Date","now","nextSegment","setReceivedBytes","getTransferredBytes","isDone","display","transferredBytes","percentage","toFixed","elapsedTime","downloadSpeed","onProgress","progress","loadedBytes","startDisplayTimer","delayInMs","displayCallback","timeoutHandle","setTimeout","stopDisplayTimer","clearTimeout","writeStream","createWriteStream","downloadResponse","socket","destroy","contentLengthHeader","expectedLength","parseInt","actualLength","archiveDescriptor","promises","open","socketTimeout","timeoutInMs","keepAlive","res","request","lengthHeader","Number","isNaN","downloads","blockSize","count","promiseGetter","downloadSegmentRetry","reverse","actives","bytesDownloaded","progressFn","activeDownloads","nextDownload","waitAndWrite","segment","race","values","write","pop","downloadConcurrency","dispose","close","retries","failures","timeout","promiseWithTimeout","downloadSegment","partRes","Range","readBodyBuffer","client","BlockBlobClient","retryOptions","tryTimeoutInMs","properties","getProperties","maxSegmentSize","constants"Line truncated
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__setModuleDefault","v","value","__importStar","mod","result","prototype","hasOwnProperty","call","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","exports","saveCache","restoreCache","isFeatureAvailable","ReserveCacheError","ValidationError","core","__webpack_require__","path","utils","cacheHttpClient","tar_1","Error","constructor","message","super","name","setPrototypeOf","checkPaths","paths","length","checkKey","key","regex","test","process","env","primaryKey","restoreKeys","options","enableCrossOsArchive","keys","debug","JSON","stringify","compressionMethod","getCompressionMethod","archivePath","cacheEntry","getCacheEntry","archiveLocation","lookupOnly","info","cacheKey","join","createTempDirectory","getCacheFileName","downloadCache","isDebug","listTar","archiveFileSize","getArchiveFileSizeInBytes","Math","round","extractTar","error","typedError","warning","unlinkFile","_a","_b","_c","_d","_e","cacheId","cachePaths","resolvePaths","archiveFolder","createTar","fileSizeLimit","isGhes","reserveCacheResponse","reserveCache","cacheSize","statusCode","getCacheVersion","http_client_1","auth_1","crypto","fs","url_1","downloadUtils_1","options_1","requestUtils_1","versionSalt","getCacheApiUrl","resource","baseUrl","url","createAcceptHeader","type","apiVersion","getRequestOptions","requestOptions","headers","Accept","createHttpClient","token","bearerCredentialHandler","BearerCredentialHandler","HttpClient","components","push","platform","createHash","update","digest","httpClient","version","encodeURIComponent","response","retryTypedResponse","getJson","printCachesListForDiagnostics","isSuccessStatusCode","cacheResult","cacheDownloadUrl","setSecret","cacheListResult","totalCount","artifactCaches","cacheVersion","scope","creationTime","archiveUrl","URL","downloadOptions","getDownloadOptions","hostname","endsWith","useAzureSdk","downloadCacheStorageSDK","concurrentBlobDownloads","downloadCacheHttpClientConcurrent","downloadCacheHttpClient","reserveCacheRequest","postJson","getContentRange","start","end","uploadChunk","resourceUrl","openStream","additionalHeaders","uploadChunkResponse","retryHttpClientResponse","sendStream","uploadFile","fileSize","toString","fd","openSync","uploadOptions","getUploadOptions","concurrency","assertDefined","uploadConcurrency","maxChunkSize","uploadChunkSize","parallelUploads","Array","offset","all","map","chunkSize","min","createReadStream","autoClose","on","closeSync","commitCache","filesize","commitCacheRequest","size","commitCacheResponse","__asyncValues","Symbol","asyncIterator","TypeError","i","__values","iterator","verb","n","settle","d","getGnuTarPathOnWindows","exec","glob","io","semver","util","uuid_1","constants_1","IS_WINDOWS","tempDirectory","baseLocation","dest","v4","mkdirP","filePath","statSync","patterns","e_1","workspace","cwd","globber","implicitDescendants","_f","globGenerator","_g","file","relativeFile","relative","replace","RegExp","sep","e_1_1","return","promisify","unlink","getVersion","app","additionalArgs","versionOutput","ignoreReturnCode","silent","listeners","stdout","data","stderr","err","trim","clean","CompressionMethod","Gzip","ZstdWithoutLong","CacheFilename","Zstd","existsSync","GnuTarPathOnWindows","toLowerCase","includes","which","ghUrl","toUpperCase","ManifestFilename","TarFilename","SystemTarPathOnWindows","SocketTimeout","DefaultRetryDelay","DefaultRetryAttempts","ArchiveToolType","DownloadProgress","storage_blob_1","buffer","stream","abort_controller_1","pipeResponseToStream","output","pipeline","contentLength","segmentIndex","segmentSize","segmentOffset","receivedBytes","displayedComplete","startTime","Date","now","nextSegment","setReceivedBytes","getTransferredBytes","isDone","display","transferredBytes","percentage","toFixed","elapsedTime","downloadSpeed","onProgress","progress","loadedBytes","startDisplayTimer","delayInMs","displayCallback","timeoutHandle","setTimeout","stopDisplayTimer","clearTimeout","writeStream","createWriteStream","downloadResponse","socket","destroy","contentLengthHeader","expectedLength","parseInt","actualLength","archiveDescriptor","promises","open","socketTimeout","timeoutInMs","keepAlive","res","request","lengthHeader","Number","isNaN","downloads","blockSize","count","promiseGetter","downloadSegmentRetry","reverse","actives","bytesDownloaded","progressFn","activeDownloads","nextDownload","waitAndWrite","segment","race","values","write","pop","downloadConcurrency","dispose","close","retries","failures","timeout","promiseWithTimeout","downloadSegment","partRes","Range","readBodyBuffer","client","BlockBlobClient","retryOptions","tryTimeoutInMs","properties","getProperties","maxSegmentSize","constants"Line truncated
+23 -4
View File
@@ -74,19 +74,38 @@ actionsToolkit.run(
setOutput('labels', labels.join(inputs.sepLabels));
});
// Annotations
const alevels = process.env.DOCKER_METADATA_ANNOTATIONS_LEVELS || 'manifest';
if (labels.length > 0) {
await core.group(`Annotations`, async () => {
const annotations: Array<string> = [];
for (const level of alevels.split(',')) {
annotations.push(
...labels.map(label => {
const v = `${level}:${label}`;
core.info(v);
return v;
})
);
}
setOutput(`annotations`, annotations.join(inputs.sepLabels));
});
}
// JSON
const jsonOutput = meta.getJSON();
const jsonOutput = meta.getJSON(alevels.split(','));
await core.group(`JSON output`, async () => {
core.info(JSON.stringify(jsonOutput, null, 2));
setOutput('json', JSON.stringify(jsonOutput));
});
// Bake files
for (const kind of ['tags', 'labels']) {
for (const kind of ['tags', 'labels', 'annotations:' + alevels]) {
const outputName = kind.split(':')[0];
const bakeFile: string = meta.getBakeFile(kind);
await core.group(`Bake file definition (${kind})`, async () => {
await core.group(`Bake file definition (${outputName})`, async () => {
core.info(fs.readFileSync(bakeFile, 'utf8'));
setOutput(`bake-file-${kind}`, bakeFile);
setOutput(`bake-file-${outputName}`, bakeFile);
});
}
+35 -23
View File
@@ -480,7 +480,11 @@ export class Meta {
.map(([key, value]) => `${key}=${value}`);
}
public getJSON(): unknown {
public getJSON(alevels: string[]): unknown {
const annotations: Array<string> = [];
for (const level of alevels) {
annotations.push(...this.getLabels().map(label => `${level}:${label}`));
}
return {
tags: this.getTags(),
labels: this.getLabels().reduce((res, label) => {
@@ -490,34 +494,42 @@ export class Meta {
}
res[matches[1]] = matches[2];
return res;
}, {})
}, {}),
annotations: annotations
};
}
public getBakeFile(kind: string): string {
switch (kind) {
case 'tags':
return this.generateBakeFile(kind, {
tags: this.getTags(),
args: {
DOCKER_META_IMAGES: this.getImageNames().join(','),
DOCKER_META_VERSION: this.version.main
}
});
case 'labels':
return this.generateBakeFile(kind, {
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
if (!matches) {
return res;
}
res[matches[1]] = matches[2];
if (kind == 'tags') {
return this.generateBakeFile(kind, {
tags: this.getTags(),
args: {
DOCKER_META_IMAGES: this.getImageNames().join(','),
DOCKER_META_VERSION: this.version.main
}
});
} else if (kind == 'labels') {
return this.generateBakeFile(kind, {
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
if (!matches) {
return res;
}, {})
});
default:
throw new Error(`Unknown bake file type: ${kind}`);
}
res[matches[1]] = matches[2];
return res;
}, {})
});
} else if (kind.startsWith('annotations:')) {
const name = kind.split(':')[0];
const annotations: Array<string> = [];
for (const level of kind.split(':')[1].split(',')) {
annotations.push(...this.getLabels().map(label => `${level}:${label}`));
}
return this.generateBakeFile(name, {
annotations: annotations
});
}
throw new Error(`Unknown bake file type: ${kind}`);
}
public getBakeFileTagsLabels(): string {