Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom annotations support #361

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

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

| 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 |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
| 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
-
7 changes: 7 additions & 0 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
@@ -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
],
Loading