Skip to content

Commit e6428a5

Browse files
authored
Merge pull request #361 from crazy-max/custom-annotations
custom annotations support
2 parents 26b4721 + 352ce8b commit e6428a5

File tree

11 files changed

+301
-151
lines changed

11 files changed

+301
-151
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
name=ghcr.io/name/app,enable=${{ github.event_name == 'pull_request' }}
166166
name=ghcr.io/name/release,enable=${{ startsWith(github.ref, 'refs/tags/') }}
167167
168-
labels:
168+
custom-labels-annotations:
169169
runs-on: ubuntu-latest
170170
steps:
171171
-
@@ -183,6 +183,11 @@ jobs:
183183
org.opencontainers.image.title=MyCustomTitle
184184
org.opencontainers.image.description=this is a "good" example
185185
org.opencontainers.image.vendor=MyCompany
186+
annotations: |
187+
maintainer=Foo
188+
org.opencontainers.image.title=MyFooTitle
189+
org.opencontainers.image.description=this is a "foo" example
190+
org.opencontainers.image.vendor=MyFooCompany
186191
187192
global-exps:
188193
runs-on: ubuntu-latest
@@ -372,6 +377,8 @@ jobs:
372377
ghcr.io/name/app
373378
labels: |
374379
maintainer=CrazyMax
380+
annotations: |
381+
maintainer=Foo
375382
-
376383
name: Build
377384
uses: docker/build-push-action@v5
@@ -382,6 +389,7 @@ jobs:
382389
DOCKER_METADATA_OUTPUT_VERSION
383390
DOCKER_METADATA_OUTPUT_TAGS
384391
DOCKER_METADATA_OUTPUT_LABELS
392+
DOCKER_METADATA_OUTPUT_ANNOTATIONS
385393
DOCKER_METADATA_OUTPUT_JSON
386394
387395
bake-annotations:

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ___
4747
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
4848
* [Major version zero](#major-version-zero)
4949
* [JSON output object](#json-output-object)
50-
* [Overwrite labels](#overwrite-labels)
50+
* [Overwrite labels and annotations](#overwrite-labels-and-annotations)
5151
* [Annotations](#annotations)
5252
* [Contributing](#contributing)
5353

@@ -293,16 +293,18 @@ The following inputs can be used as `step.with` keys:
293293
> org.opencontainers.image.vendor=MyCompany
294294
> ```
295295

296-
| Name | Type | Description |
297-
|---------------|--------|-------------------------------------------------------------------------------|
298-
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
299-
| `images` | List | List of Docker images to use as base name for tags |
300-
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
301-
| `flavor` | List | [Flavor](#flavor-input) to apply |
302-
| `labels` | List | List of custom labels |
303-
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
304-
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
305-
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
296+
| Name | Type | Description |
297+
|-------------------|--------|------------------------------------------------------------------------------|
298+
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
299+
| `images` | List | List of Docker images to use as base name for tags |
300+
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
301+
| `flavor` | List | [Flavor](#flavor-input) to apply |
302+
| `labels` | List | List of custom labels |
303+
| `annotations` | List | List of custom anntoations |
304+
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
305+
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
306+
| `sep-annotations` | String | Separator to use for annotations output (default `\n`) |
307+
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
306308

307309
### outputs
308310

@@ -893,10 +895,11 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
893895
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
894896
```
895897

896-
### Overwrite labels
898+
### Overwrite labels and annotations
897899

898900
If some [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
899-
labels generated are not suitable, you can overwrite them like this:
901+
generated are not suitable as labels/annotations, you can overwrite them like
902+
this:
900903

901904
```yaml
902905
-

__tests__/context.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ describe('getInputs', () => {
3939
githubToken: '',
4040
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
4141
labels: [],
42+
annotations: [],
4243
sepLabels: '\n',
4344
sepTags: '\n',
45+
sepAnnotations: '\n',
4446
tags: [],
4547
} as Inputs
4648
],
@@ -51,6 +53,7 @@ describe('getInputs', () => {
5153
['images', 'moby/buildkit'],
5254
['sep-labels', ','],
5355
['sep-tags', ','],
56+
['sep-annotations', ',']
5457
]),
5558
{
5659
context: ContextSource.workflow,
@@ -59,8 +62,10 @@ describe('getInputs', () => {
5962
githubToken: '',
6063
images: ['moby/buildkit'],
6164
labels: [],
65+
annotations: [],
6266
sepLabels: ',',
6367
sepTags: ',',
68+
sepAnnotations: ',',
6469
tags: [],
6570
} as Inputs
6671
],
@@ -76,8 +81,10 @@ describe('getInputs', () => {
7681
githubToken: '',
7782
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
7883
labels: [],
84+
annotations: [],
7985
sepLabels: '\n',
8086
sepTags: '\n',
87+
sepAnnotations: '\n',
8188
tags: [],
8289
} as Inputs
8390
],

0 commit comments

Comments
 (0)