Compare commits

...

27 Commits

Author SHA1 Message Date
CrazyMax
dbef88086f Merge pull request #374 from docker/dependabot/npm_and_yarn/moment-timezone-0.5.44
chore(deps): Bump moment-timezone from 0.5.43 to 0.5.44
2024-01-05 10:58:01 +01:00
CrazyMax
b73e7a71ac chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-05 10:56:26 +01:00
dependabot[bot]
b9fba690eb chore(deps): Bump moment-timezone from 0.5.43 to 0.5.44
Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.43 to 0.5.44.
- [Release notes](https://github.com/moment/moment-timezone/releases)
- [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md)
- [Commits](https://github.com/moment/moment-timezone/compare/0.5.43...0.5.44)

---
updated-dependencies:
- dependency-name: moment-timezone
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-05 09:54:17 +00:00
CrazyMax
ac82374ba6 Merge pull request #373 from docker/dependabot/npm_and_yarn/moment-2.30.1
chore(deps): Bump moment from 2.29.4 to 2.30.1
2024-01-05 10:51:59 +01:00
CrazyMax
c92519a44e chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-05 10:50:35 +01:00
dependabot[bot]
3b4179d34d chore(deps): Bump moment from 2.29.4 to 2.30.1
Bumps [moment](https://github.com/moment/moment) from 2.29.4 to 2.30.1.
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.4...2.30.1)

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-05 10:49:11 +01:00
CrazyMax
0784993ef8 Merge pull request #371 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.16.1
chore(deps): Bump @docker/actions-toolkit from 0.16.0 to 0.16.1
2024-01-05 10:48:32 +01:00
CrazyMax
52c3e9e410 chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-05 10:46:26 +01:00
dependabot[bot]
82a5e6726c chore(deps): Bump @docker/actions-toolkit from 0.16.0 to 0.16.1
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.16.0 to 0.16.1.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.16.0...v0.16.1)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-05 09:44:28 +00:00
Tõnis Tiigi
41e1fe3437 Merge pull request #370 from crazy-max/bake-cwd
bake: set cwd:// prefix for bake files path
2024-01-04 09:32:49 -08:00
CrazyMax
48cce1cba0 chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-04 10:09:14 +01:00
CrazyMax
61879b94bc bake: set cwd:// prefix for bake files path
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-04 10:09:06 +01:00
CrazyMax
36ea4ee555 bake: refactor generateBakeFile
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-12-20 14:48:27 +01:00
CrazyMax
74fa878183 ci: bump buildx to latest
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-12-20 14:38:48 +01:00
CrazyMax
9dc751fe24 Merge pull request #369 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.16.0
chore(deps): Bump @docker/actions-toolkit from 0.15.0 to 0.16.0
2023-12-18 11:47:58 +01:00
CrazyMax
c94c54c4e6 chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-12-15 20:46:50 +01:00
dependabot[bot]
187f09259d chore(deps): Bump @docker/actions-toolkit from 0.15.0 to 0.16.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.15.0 to 0.16.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.15.0...v0.16.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 19:45:27 +00:00
CrazyMax
6d6eaf3451 Merge pull request #365 from docker/dependabot/npm_and_yarn/csv-parse-5.5.3
chore(deps): Bump csv-parse from 5.5.2 to 5.5.3
2023-12-15 20:44:33 +01:00
dependabot[bot]
1484a7ec95 chore(deps): Bump csv-parse from 5.5.2 to 5.5.3
Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 5.5.2 to 5.5.3.
- [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
- [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.5.3/packages/csv-parse)

---
updated-dependencies:
- dependency-name: csv-parse
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 19:40:22 +00:00
CrazyMax
31cebacef4 Merge pull request #363 from docker/dependabot/npm_and_yarn/docker/actions-toolkit-0.15.0
chore(deps): Bump @docker/actions-toolkit from 0.14.0 to 0.15.0
2023-12-04 01:51:22 -08:00
CrazyMax
394bbab10c chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-12-04 10:49:19 +01:00
dependabot[bot]
ee4c9054ec chore(deps): Bump @docker/actions-toolkit from 0.14.0 to 0.15.0
Bumps [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.14.0 to 0.15.0.
- [Release notes](https://github.com/docker/actions-toolkit/releases)
- [Commits](https://github.com/docker/actions-toolkit/compare/v0.14.0...v0.15.0)

---
updated-dependencies:
- dependency-name: "@docker/actions-toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 09:39:45 +00:00
Tõnis Tiigi
e6428a5c4e Merge pull request #361 from crazy-max/custom-annotations
custom annotations support
2023-11-30 09:29:27 -08:00
David Karlsson
26b4721af7 Merge pull request #359 from favonia/document-annotations
docs(README): add a hint about multi-arch builds
2023-11-30 15:35:34 +01:00
CrazyMax
352ce8b7fe chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 15:09:51 +01:00
CrazyMax
cb0becceaf custom annotations support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-30 15:09:51 +01:00
favonia
91224bc155 docs(README): add a hint about multi-arch builds
Document probably the most common usage of
`DOCKER_METADATA_ANNOTATIONS_LEVELS`: multi-arch builds.

Signed-off-by: favonia <favonia@gmail.com>
2023-11-30 06:53:25 -06:00
13 changed files with 425 additions and 241 deletions

View File

@@ -165,7 +165,7 @@ jobs:
name=ghcr.io/name/app,enable=${{ github.event_name == 'pull_request' }}
name=ghcr.io/name/release,enable=${{ startsWith(github.ref, 'refs/tags/') }}
labels:
custom-labels-annotations:
runs-on: ubuntu-latest
steps:
-
@@ -183,6 +183,11 @@ jobs:
org.opencontainers.image.title=MyCustomTitle
org.opencontainers.image.description=this is a "good" example
org.opencontainers.image.vendor=MyCompany
annotations: |
maintainer=Foo
org.opencontainers.image.title=MyFooTitle
org.opencontainers.image.description=this is a "foo" example
org.opencontainers.image.vendor=MyFooCompany
global-exps:
runs-on: ubuntu-latest
@@ -372,6 +377,8 @@ jobs:
ghcr.io/name/app
labels: |
maintainer=CrazyMax
annotations: |
maintainer=Foo
-
name: Build
uses: docker/build-push-action@v5
@@ -382,6 +389,7 @@ jobs:
DOCKER_METADATA_OUTPUT_VERSION
DOCKER_METADATA_OUTPUT_TAGS
DOCKER_METADATA_OUTPUT_LABELS
DOCKER_METADATA_OUTPUT_ANNOTATIONS
DOCKER_METADATA_OUTPUT_JSON
bake-annotations:
@@ -416,7 +424,7 @@ jobs:
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.0-rc1
version: latest
-
name: Build
uses: docker/bake-action@v4
@@ -447,3 +455,29 @@ jobs:
-
name: Print envs
run: env|sort
bake-cwd:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
-
name: Docker meta
id: docker_meta
uses: ./
-
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-labels }}
targets: |
release

View File

@@ -47,7 +47,7 @@ ___
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
* [Major version zero](#major-version-zero)
* [JSON output object](#json-output-object)
* [Overwrite labels](#overwrite-labels)
* [Overwrite labels and annotations](#overwrite-labels-and-annotations)
* [Annotations](#annotations)
* [Contributing](#contributing)
@@ -294,14 +294,16 @@ The following inputs can be used as `step.with` keys:
> ```
| Name | Type | Description |
|---------------|--------|-------------------------------------------------------------------------------|
|-------------------|--------|------------------------------------------------------------------------------|
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
| `images` | List | List of Docker images to use as base name for tags |
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
| `flavor` | List | [Flavor](#flavor-input) to apply |
| `labels` | List | List of custom labels |
| `annotations` | List | List of custom anntoations |
| `sep-tags` | String | Separator to use for tags 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`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
### outputs
@@ -893,10 +895,11 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
```
### Overwrite labels
### Overwrite labels and annotations
If some [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
labels generated are not suitable, you can overwrite them like this:
generated are not suitable as labels/annotations, you can overwrite them like
this:
```yaml
-
@@ -954,9 +957,17 @@ The same can be done with the [`bake-action`](https://github.com/docker/bake-act
targets: build
```
If you want to set specific level(s) for your annotations, you can use the
Note that annotations can be attached at many different levels within a manifest.
By default, the generated annotations will be attached to image manifests,
but different registries may expect annotations at different places;
a common practice is to read annotations at _image indexes_ if present,
which are often used by multi-arch builds to index platform-specific images.
If you want to specify 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`):
with a comma separated list of all levels the annotations should be attached to (defaults to `manifest`).
The following configuration demonstrates the ability to attach annotations to both image manifests and image indexes,
though your registry may only need annotations at the index level. (That is, `index` alone may be enough.)
Please consult the documentation of your registry.
```yaml
-

View File

@@ -39,8 +39,10 @@ describe('getInputs', () => {
githubToken: '',
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
labels: [],
annotations: [],
sepLabels: '\n',
sepTags: '\n',
sepAnnotations: '\n',
tags: [],
} as Inputs
],
@@ -51,6 +53,7 @@ describe('getInputs', () => {
['images', 'moby/buildkit'],
['sep-labels', ','],
['sep-tags', ','],
['sep-annotations', ',']
]),
{
context: ContextSource.workflow,
@@ -59,8 +62,10 @@ describe('getInputs', () => {
githubToken: '',
images: ['moby/buildkit'],
labels: [],
annotations: [],
sepLabels: ',',
sepTags: ',',
sepAnnotations: ',',
tags: [],
} as Inputs
],
@@ -76,8 +81,10 @@ describe('getInputs', () => {
githubToken: '',
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
labels: [],
annotations: [],
sepLabels: '\n',
sepTags: '\n',
sepAnnotations: '\n',
tags: [],
} as Inputs
],

View File

@@ -49,7 +49,7 @@ describe('isRawStatement', () => {
});
});
const tagsLabelsTest = async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabels: Array<string>) => {
const tagsLabelsTest = async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabels: Array<string>, exAnnotations: Array<string> | undefined) => {
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
const toolkit = new Toolkit();
const repo = await toolkit.github.repoData();
@@ -63,6 +63,9 @@ const tagsLabelsTest = async (name: string, envFile: string, inputs: Inputs, exV
const labels = meta.getLabels();
expect(labels).toEqual(exLabels);
const annotations = meta.getAnnotations();
expect(annotations).toEqual(exAnnotations ?? exLabels);
};
describe('null', () => {
@@ -90,7 +93,8 @@ describe('null', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version="
]
],
undefined
],
[
'null02',
@@ -117,7 +121,8 @@ describe('null', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version="
]
],
undefined
],
])('given %p with %p event', tagsLabelsTest);
});
@@ -149,7 +154,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'push02',
@@ -177,7 +183,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push03',
@@ -202,7 +209,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=master"
]
],
undefined
],
[
'push04',
@@ -230,7 +238,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push05',
@@ -256,7 +265,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'push06',
@@ -285,7 +295,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push07',
@@ -317,7 +328,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'push08',
@@ -349,7 +361,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push09',
@@ -381,7 +394,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push10',
@@ -411,7 +425,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-2665741"
]
],
undefined
],
[
'push11',
@@ -441,7 +456,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-983315b"
]
],
undefined
],
[
'push12',
@@ -469,7 +485,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version="
]
],
undefined
],
[
'push13',
@@ -499,7 +516,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=master"
]
],
undefined
],
[
'push14',
@@ -531,7 +549,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.2.3"
]
],
undefined
],
[
'push15',
@@ -562,7 +581,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.2.3"
]
],
undefined
],
[
'push16',
@@ -591,7 +611,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=edge"
]
],
undefined
],
[
'push17',
@@ -635,7 +656,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=mytag-master"
]
],
undefined
],
[
'push18',
@@ -667,7 +689,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'push19',
@@ -699,7 +722,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-860c1904a1ce19322e91ac35af1ab07466440c37"
]
],
undefined
],
[
'push20',
@@ -732,7 +756,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-860c1904a1ce19322e91ac35af1ab07466440c37"
]
],
undefined
],
[
'push21',
@@ -776,7 +801,8 @@ describe('push', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=mytag-master"
]
],
undefined
]
])('given %p with %p event', tagsLabelsTest);
});
@@ -809,7 +835,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=release1"
]
],
undefined
],
[
'tag02',
@@ -835,7 +862,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110-RC2"
]
],
undefined
],
[
'tag03',
@@ -866,7 +894,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110"
]
],
undefined
],
[
'tag04',
@@ -897,7 +926,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110"
]
],
undefined
],
[
'tag05',
@@ -928,7 +958,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'tag06',
@@ -959,7 +990,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'tag07',
@@ -990,7 +1022,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0.8-beta.67"
]
],
undefined
],
[
'tag08',
@@ -1021,7 +1054,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0"
]
],
undefined
],
[
'tag09',
@@ -1055,7 +1089,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0.8"
]
],
undefined
],
[
'tag10',
@@ -1081,7 +1116,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version="
]
],
undefined
],
[
'tag11',
@@ -1118,7 +1154,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'tag12',
@@ -1150,7 +1187,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'tag13',
@@ -1180,7 +1218,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0.8-beta.67"
]
],
undefined
],
[
'tag14',
@@ -1214,7 +1253,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sometag"
]
],
undefined
],
[
'tag15',
@@ -1249,7 +1289,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=foo"
]
],
undefined
],
[
'tag16',
@@ -1282,7 +1323,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=foo"
]
],
undefined
],
[
'tag17',
@@ -1321,7 +1363,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0"
]
],
undefined
],
[
'tag18',
@@ -1360,7 +1403,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0"
]
],
undefined
],
[
'tag19',
@@ -1401,7 +1445,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0-dev"
]
],
undefined
],
[
'tag20',
@@ -1436,7 +1481,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1-860c190-foo"
]
],
undefined
],
[
'tag21',
@@ -1471,7 +1517,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1-dev"
]
],
undefined
],
[
'tag22',
@@ -1507,7 +1554,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=foo-1.1.1-dev"
]
],
undefined
],
[
'tag23',
@@ -1538,7 +1586,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
],
[
'tag24',
@@ -1568,7 +1617,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.2"
]
],
undefined
],
[
'tag25',
@@ -1598,7 +1648,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1b2"
]
],
undefined
],
[
'tag26',
@@ -1628,7 +1679,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.dev4"
]
],
undefined
],
[
'tag27',
@@ -1660,7 +1712,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.2.3rc2"
]
],
undefined
],
[
'tag28',
@@ -1697,7 +1750,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'tag29',
@@ -1727,7 +1781,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.2.post1"
]
],
undefined
],
[
'tag30',
@@ -1761,7 +1816,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sometag"
]
],
undefined
],
[
'tag31',
@@ -1790,7 +1846,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v2.0.8-beta.67"
]
],
undefined
],
[
'tag32',
@@ -1822,7 +1879,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.2.3rc2"
]
],
undefined
],
[
'tag33',
@@ -1859,7 +1917,8 @@ describe('tag', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
]
])('given %p with %p event', tagsLabelsTest);
});
@@ -1895,7 +1954,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=release1"
]
],
undefined
],
[
'latest02',
@@ -1924,7 +1984,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110-RC2"
]
],
undefined
],
[
'latest03',
@@ -1953,7 +2014,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110"
]
],
undefined
],
[
'latest04',
@@ -1982,7 +2044,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'latest05',
@@ -2010,7 +2073,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
],
[
'latest06',
@@ -2041,7 +2105,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0.8"
]
],
undefined
],
[
'latest07',
@@ -2073,7 +2138,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
],
[
'latest08',
@@ -2105,7 +2171,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
],
[
'latest09',
@@ -2123,6 +2190,12 @@ describe('latest', () => {
`org.opencontainers.image.description=this is a "good" example`,
"org.opencontainers.image.title=MyCustomTitle",
"org.opencontainers.image.vendor=MyCompany",
],
annotations: [
"maintainer=Foo",
`org.opencontainers.image.description=this is a "bad" example`,
"org.opencontainers.image.title=MyNotTitle",
"org.opencontainers.image.vendor=MyNotCompany",
]
} as Inputs,
{
@@ -2145,6 +2218,18 @@ describe('latest', () => {
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.vendor=MyCompany",
"org.opencontainers.image.version=v1.1.1"
],
[
"maintainer=Foo",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
`org.opencontainers.image.description=this is a "bad" example`,
"org.opencontainers.image.licenses=MIT",
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=MyNotTitle",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.vendor=MyNotCompany",
"org.opencontainers.image.version=v1.1.1"
]
],
[
@@ -2174,7 +2259,8 @@ describe('latest', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2.0.8"
]
],
undefined
]
])('given %p with %p event', tagsLabelsTest);
});
@@ -2206,7 +2292,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-15"
]
],
undefined
],
[
'pr02',
@@ -2232,7 +2319,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-15"
]
],
undefined
],
[
'pr03',
@@ -2264,7 +2352,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-15"
]
],
undefined
],
[
'pr04',
@@ -2296,7 +2385,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-a9c8c58"
]
],
undefined
],
[
'pr05',
@@ -2329,7 +2419,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-15-bal"
]
],
undefined
],
[
'pr06',
@@ -2362,7 +2453,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=15-bal"
]
],
undefined
],
[
'pr07',
@@ -2394,7 +2486,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-2665741"
]
],
undefined
],
[
'pr08',
@@ -2427,7 +2520,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=15-bal"
]
],
undefined
],
[
'pr09',
@@ -2464,7 +2558,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-15"
]
],
undefined
],
[
'pr10',
@@ -2493,7 +2588,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=mytag-master"
]
],
undefined
],
[
'pr11',
@@ -2522,7 +2618,8 @@ describe('pr', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=mytag-master"
]
],
undefined
],
])('given %p with %p event', tagsLabelsTest);
});
@@ -2872,7 +2969,7 @@ describe('pr-head-sha', () => {
"org.opencontainers.image.version=mytag-master"
]
],
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabels: Array<string>) => {
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabelsAnnotations: Array<string>) => {
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
process.env.DOCKER_METADATA_PR_HEAD_SHA = 'true';
@@ -2887,7 +2984,10 @@ describe('pr-head-sha', () => {
expect(tags).toEqual(exTags);
const labels = meta.getLabels();
expect(labels).toEqual(exLabels);
expect(labels).toEqual(exLabelsAnnotations);
const annotations = meta.getAnnotations();
expect(annotations).toEqual(exLabelsAnnotations);
});
});
@@ -2919,7 +3019,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=nightly"
]
],
undefined
],
[
'schedule02',
@@ -2947,7 +3048,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110"
]
],
undefined
],
[
'schedule03',
@@ -2975,7 +3077,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110-003000"
]
],
undefined
],
[
'schedule04',
@@ -3003,7 +3106,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=nightly"
]
],
undefined
],
[
'schedule05',
@@ -3035,7 +3139,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=nightly"
]
],
undefined
],
[
'schedule06',
@@ -3073,7 +3178,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-860c190"
]
],
undefined
],
[
'schedule07',
@@ -3106,7 +3212,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=glo-nightly-bal"
]
],
undefined
],
[
'schedule08',
@@ -3134,7 +3241,8 @@ describe('schedule', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110-093000"
]
],
undefined
],
])('given %p with %p event', tagsLabelsTest);
});
@@ -3167,7 +3275,8 @@ describe('release', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
],
[
'release02',
@@ -3201,7 +3310,8 @@ describe('release', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1"
]
],
undefined
]
])('given %s with %p event', tagsLabelsTest);
});
@@ -3242,7 +3352,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'raw02',
@@ -3272,7 +3383,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=dev"
]
],
undefined
],
[
'raw03',
@@ -3307,7 +3419,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=release1"
]
],
undefined
],
[
'raw04',
@@ -3344,7 +3457,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=20200110"
]
],
undefined
],
[
'raw05',
@@ -3390,7 +3504,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.1.1"
]
],
undefined
],
[
'raw06',
@@ -3425,7 +3540,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=my"
]
],
undefined
],
[
'raw07',
@@ -3463,7 +3579,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=my"
]
],
undefined
],
[
'raw08',
@@ -3499,7 +3616,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=my"
]
],
undefined
],
[
'raw09',
@@ -3537,7 +3655,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=foo-my-bar"
]
],
undefined
],
[
'raw10',
@@ -3571,7 +3690,8 @@ describe('raw', () => {
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=foo"
]
],
undefined
],
])('given %p wth %p event', tagsLabelsTest);
});
@@ -3615,7 +3735,6 @@ describe('json', () => {
"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",
@@ -3877,15 +3996,13 @@ describe('json', () => {
"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.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=MyCustom=Title",
"manifest:org.opencontainers.image.title=Hello-World",
"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"
]
}
@@ -4385,25 +4502,21 @@ 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.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=MyCustom=Title",
"index:org.opencontainers.image.title=Hello-World",
"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.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=MyCustom=Title",
"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.vendor=MyCompany",
"manifest-descriptor:org.opencontainers.image.version=v1.1.1"
]
}

View File

@@ -23,12 +23,18 @@ inputs:
labels:
description: 'List of custom labels'
required: false
annotations:
description: 'List of custom annotations'
required: false
sep-tags:
description: 'Separator to use for tags output (default \n)'
required: false
sep-labels:
description: 'Separator to use for labels output (default \n)'
required: false
sep-annotations:
description: 'Separator to use for annotations output (default \n)'
required: false
bake-target:
description: 'Bake target name (default docker-metadata-action)'
required: false

14
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -29,12 +29,12 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@docker/actions-toolkit": "^0.14.0",
"@docker/actions-toolkit": "^0.16.1",
"@renovate/pep440": "^1.0.0",
"csv-parse": "^5.5.2",
"csv-parse": "^5.5.3",
"handlebars": "^4.7.8",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"moment": "^2.30.1",
"moment-timezone": "^0.5.44",
"semver": "^7.5.4"
},
"devDependencies": {

View File

@@ -10,8 +10,10 @@ export interface Inputs {
tags: string[];
flavor: string[];
labels: string[];
annotations: string[];
sepTags: string;
sepLabels: string;
sepAnnotations: string;
bakeTarget: string;
githubToken: string;
}
@@ -23,8 +25,10 @@ export function getInputs(): Inputs {
tags: Util.getInputList('tags', {ignoreComma: true, comment: '#'}),
flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#'}),
labels: Util.getInputList('labels', {ignoreComma: true, comment: '#'}),
annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#'}),
sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`,
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
githubToken: core.getInput('github-token')
};

View File

@@ -71,41 +71,45 @@ actionsToolkit.run(
});
// Annotations
const alevels = process.env.DOCKER_METADATA_ANNOTATIONS_LEVELS || 'manifest';
if (labels.length > 0) {
const annotationsRaw: Array<string> = meta.getAnnotations();
const annotationsLevels = process.env.DOCKER_METADATA_ANNOTATIONS_LEVELS || 'manifest';
await core.group(`Annotations`, async () => {
const annotations: Array<string> = [];
for (const level of alevels.split(',')) {
for (const level of annotationsLevels.split(',')) {
annotations.push(
...labels.map(label => {
...annotationsRaw.map(label => {
const v = `${level}:${label}`;
core.info(v);
return v;
})
);
}
setOutput(`annotations`, annotations.join(inputs.sepLabels));
setOutput(`annotations`, annotations.join(inputs.sepAnnotations));
});
}
// JSON
const jsonOutput = meta.getJSON(alevels.split(','));
const jsonOutput = meta.getJSON(annotationsLevels.split(','));
await core.group(`JSON output`, async () => {
core.info(JSON.stringify(jsonOutput, null, 2));
setOutput('json', JSON.stringify(jsonOutput));
});
// Specifying local and remote bake files is supported since Buildx 0.12.0.
// Set cwd:// prefix for local bake files to avoid ambiguity with remote
// https://github.com/docker/buildx/pull/1838
const bakeFileCwdPrefix = (await toolkit.buildx.versionSatisfies('>=0.12.0').catch(() => false)) ? 'cwd://' : '';
// Bake files
for (const kind of ['tags', 'labels', 'annotations:' + alevels]) {
for (const kind of ['tags', 'labels', 'annotations:' + annotationsLevels]) {
const outputName = kind.split(':')[0];
const bakeFile: string = meta.getBakeFile(kind);
await core.group(`Bake file definition (${outputName})`, async () => {
core.info(fs.readFileSync(bakeFile, 'utf8'));
setOutput(`bake-file-${outputName}`, bakeFile);
setOutput(`bake-file-${outputName}`, `${bakeFileCwdPrefix}${bakeFile}`);
});
}
// Bake file with tags and labels
setOutput(`bake-file`, meta.getBakeFileTagsLabels());
setOutput(`bake-file`, `${bakeFileCwdPrefix}${meta.getBakeFileTagsLabels()}`);
}
);

View File

@@ -468,7 +468,15 @@ export class Meta {
}
public getLabels(): Array<string> {
const labels: Array<string> = [
return this.getOCIAnnotationsWithCustoms(this.inputs.labels);
}
public getAnnotations(): Array<string> {
return this.getOCIAnnotationsWithCustoms(this.inputs.annotations);
}
private getOCIAnnotationsWithCustoms(extra: string[]): Array<string> {
const res: Array<string> = [
`org.opencontainers.image.title=${this.repo.name || ''}`,
`org.opencontainers.image.description=${this.repo.description || ''}`,
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
@@ -478,11 +486,11 @@ export class Meta {
`org.opencontainers.image.revision=${this.context.sha || ''}`,
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
];
labels.push(...this.inputs.labels);
res.push(...extra);
return Array.from(
new Map<string, string>(
labels
res
.map(label => label.split('='))
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([_key, ...values]) => values.length > 0)
@@ -496,7 +504,7 @@ export class Meta {
public getJSON(alevels: string[]): unknown {
const annotations: Array<string> = [];
for (const level of alevels) {
annotations.push(...this.getLabels().map(label => `${level}:${label}`));
annotations.push(...this.getAnnotations().map(label => `${level}:${label}`));
}
return {
tags: this.getTags(),
@@ -514,15 +522,19 @@ export class Meta {
public getBakeFile(kind: string): string {
if (kind == 'tags') {
return this.generateBakeFile(kind, {
return this.generateBakeFile(
{
tags: this.getTags(),
args: {
DOCKER_META_IMAGES: this.getImageNames().join(','),
DOCKER_META_VERSION: this.version.main
}
});
},
kind
);
} else if (kind == 'labels') {
return this.generateBakeFile(kind, {
return this.generateBakeFile(
{
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
if (!matches) {
@@ -531,28 +543,27 @@ export class Meta {
res[matches[1]] = matches[2];
return res;
}, {})
});
},
kind
);
} 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}`));
annotations.push(...this.getAnnotations().map(label => `${level}:${label}`));
}
return this.generateBakeFile(name, {
return this.generateBakeFile(
{
annotations: annotations
});
},
name
);
}
throw new Error(`Unknown bake file type: ${kind}`);
}
public getBakeFileTagsLabels(): string {
const bakeFile = path.join(ToolkitContext.tmpDir(), 'docker-metadata-action-bake.json');
fs.writeFileSync(
bakeFile,
JSON.stringify(
{
target: {
[this.inputs.bakeTarget]: {
return this.generateBakeFile({
tags: this.getTags(),
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
@@ -566,18 +577,11 @@ export class Meta {
DOCKER_META_IMAGES: this.getImageNames().join(','),
DOCKER_META_VERSION: this.version.main
}
}
}
},
null,
2
)
);
return bakeFile;
});
}
private generateBakeFile(name: string, dt): string {
const bakeFile = path.join(ToolkitContext.tmpDir(), `docker-metadata-action-bake-${name}.json`);
private generateBakeFile(dt, suffix?: string): string {
const bakeFile = path.join(ToolkitContext.tmpDir(), `docker-metadata-action-bake${suffix ? `-${suffix}` : ''}.json`);
fs.writeFileSync(bakeFile, JSON.stringify({target: {[this.inputs.bakeTarget]: dt}}, null, 2));
return bakeFile;
}

View File

@@ -4,9 +4,11 @@ RUN apk add --no-cache coreutils jq
ARG DOCKER_METADATA_OUTPUT_VERSION
ARG DOCKER_METADATA_OUTPUT_TAGS
ARG DOCKER_METADATA_OUTPUT_LABELS
ARG DOCKER_METADATA_OUTPUT_ANNOTATIONS
ARG DOCKER_METADATA_OUTPUT_JSON
RUN printenv DOCKER_METADATA_OUTPUT_VERSION
RUN printenv DOCKER_METADATA_OUTPUT_TAGS
RUN printenv DOCKER_METADATA_OUTPUT_LABELS
RUN printenv DOCKER_METADATA_OUTPUT_ANNOTATIONS
RUN printenv DOCKER_METADATA_OUTPUT_JSON
RUN echo $DOCKER_METADATA_OUTPUT_JSON | jq

View File

@@ -773,10 +773,10 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"
"@docker/actions-toolkit@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.14.0.tgz#1cc7108aa1da0df708fb65915cc927d0cc420584"
integrity sha512-5PZ49FgZLcS421Py60Zm5CGzQt1OyGVVx2CHZbjr2S0Vm6Rqks4diB3io/nt4EkccUb3EgwClZPopICOPzyIPw==
"@docker/actions-toolkit@^0.16.1":
version "0.16.1"
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.16.1.tgz#797f843acee50dd3e01e976a6305ce57516b7347"
integrity sha512-RVlNRBJLBdRh3SC+GejtT0z47j5GgTc2hA3sNlWXYw7syQJON++/fgqWn7OqjCmT7c9MtdeqxwT3MTx1WvgSsw==
dependencies:
"@actions/cache" "^3.2.2"
"@actions/core" "^1.10.1"
@@ -785,12 +785,11 @@
"@actions/http-client" "^2.2.0"
"@actions/io" "^1.1.3"
"@actions/tool-cache" "^2.0.1"
"@octokit/core" "^5.0.1"
"@octokit/plugin-rest-endpoint-methods" "^10.1.5"
"@octokit/core" "^5.0.2"
"@octokit/plugin-rest-endpoint-methods" "^10.2.0"
async-retry "^1.3.3"
csv-parse "^5.5.2"
csv-parse "^5.5.3"
handlebars "^4.7.8"
js-yaml "^4.1.0"
jwt-decode "^4.0.0"
semver "^7.5.4"
tmp "^0.2.1"
@@ -1180,10 +1179,10 @@
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==
"@octokit/core@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.0.1.tgz#865da2b30d54354cccb6e30861ddfa0e24494780"
integrity sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==
"@octokit/core@^5.0.1", "@octokit/core@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.0.2.tgz#ae7c5d61fdd98ba348a27c3cc510879a130b1234"
integrity sha512-cZUy1gUvd4vttMic7C0lwPed8IYXWYp8kHIMatyhY8t8n3Cpw2ILczkV5pGMPqef7v0bLo0pOHrEHarsau2Ydg==
dependencies:
"@octokit/auth-token" "^4.0.0"
"@octokit/graphql" "^7.0.0"
@@ -1228,7 +1227,7 @@
dependencies:
"@octokit/types" "^12.0.0"
"@octokit/plugin-rest-endpoint-methods@^10.0.0", "@octokit/plugin-rest-endpoint-methods@^10.1.5":
"@octokit/plugin-rest-endpoint-methods@^10.0.0", "@octokit/plugin-rest-endpoint-methods@^10.2.0":
version "10.2.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.2.0.tgz#eeaa4de97a2ae26404dea30ce3e17b11928e027c"
integrity sha512-ePbgBMYtGoRNXDyKGvr9cyHjQ163PbwD0y1MkDJCpkO2YH4OeXX40c4wYHKikHGZcpGPbcRLuy0unPUuafco8Q==
@@ -1993,10 +1992,10 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"
csv-parse@*, csv-parse@^5.5.2:
version "5.5.2"
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.5.2.tgz#ab525e642093dccff7c5cca5c7b71fd3e99fe8f2"
integrity sha512-YRVtvdtUNXZCMyK5zd5Wty1W6dNTpGKdqQd4EQ8tl/c6KW1aMBB1Kg1ppky5FONKmEqGJ/8WjLlTNLPne4ioVA==
csv-parse@*, csv-parse@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.5.3.tgz#0261050761ee46cd0e46421854bf9bf4de1317bf"
integrity sha512-v0KW6C0qlZzoGjk6u5tLmVfyZxNgPGXZsWTXshpAgKVGmGXzaVWGdlCFxNx5iuzcXT/oJN1HHM9DZKwtAtYa+A==
debug@^4.1.0, debug@^4.1.1:
version "4.3.2"
@@ -3354,17 +3353,17 @@ minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
moment-timezone@^0.5.43:
version "0.5.43"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.43.tgz#3dd7f3d0c67f78c23cd1906b9b2137a09b3c4790"
integrity sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==
moment-timezone@^0.5.44:
version "0.5.44"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.44.tgz#a64a4e47b68a43deeab5ae4eb4f82da77cdf595f"
integrity sha512-nv3YpzI/8lkQn0U6RkLd+f0W/zy/JnoR5/EyPz/dNkPTBjA2jNLCVxaiQ8QpeLymhSZvX0wCL5s27NQWdOPwAw==
dependencies:
moment "^2.29.4"
moment@^2.29.4:
version "2.29.4"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
moment@^2.29.4, moment@^2.30.1:
version "2.30.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==
ms@2.1.2:
version "2.1.2"