4848 * [ Major version zero] ( #major-version-zero )
4949 * [ JSON output object] ( #json-output-object )
5050 * [ Overwrite labels] ( #overwrite-labels )
51+ * [ Annotations] ( #annotations )
5152* [ Contributing] ( #contributing )
5253
5354## Usage
@@ -307,23 +308,27 @@ The following inputs can be used as `step.with` keys:
307308
308309The following outputs are available :
309310
310- | Name | Type | Description |
311- |--------------------|--------|-------------------------------------------------------------------------------------------------|
312- | `version` | String | Docker image version |
313- | `tags` | String | Docker tags |
314- | `labels` | String | Docker labels |
315- | `json` | String | JSON output of tags and labels |
316- | `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
317- | `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
311+ | Name | Type | Description |
312+ |-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
313+ | `version` | String | Docker image version |
314+ | `tags` | String | Docker tags |
315+ | `labels` | String | Docker labels |
316+ | `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
317+ | `json` | String | JSON output of tags and labels |
318+ | `bake-file-tags` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with tags |
319+ | `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
320+ | `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) |
318321
319322Alternatively, each output is also exported as an environment variable :
320323
321324* `DOCKER_METADATA_OUTPUT_VERSION`
322325* `DOCKER_METADATA_OUTPUT_TAGS`
323326* `DOCKER_METADATA_OUTPUT_LABELS`
327+ * `DOCKER_METADATA_OUTPUT_ANNOTATIONS`
324328* `DOCKER_METADATA_OUTPUT_JSON`
325329* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
326330* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`
331+ * `DOCKER_METADATA_OUTPUT_BAKE_FILE_ANNOTATIONS`
327332
328333So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/) :
329334
@@ -336,9 +341,10 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
336341
337342# ## environment variables
338343
339- | Name | Type | Description |
340- |-------------------------------|------|------------------------------------------------------------------------------------------------------------|
341- | `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
344+ | Name | Type | Description |
345+ |--------------------------------------|--------|------------------------------------------------------------------------------------------------------------|
346+ | `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
347+ | `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
342348
343349# # `context` input
344350
@@ -904,6 +910,70 @@ labels generated are not suitable, you can overwrite them like this:
904910 org.opencontainers.image.vendor=MyCompany
905911` ` `
906912
913+ # ## Annotations
914+
915+ Since Buildx 0.12, it is possible to set annotations to your image through the
916+ ` --annotation` flag.
917+
918+ With the [`build-push-action`](https://github.com/docker/build-push-action/),
919+ you can set the `annotations` input with the value of the `annotations` output
920+ of the `metadata-action` :
921+
922+ ` ` ` yaml
923+ -
924+ name: Docker meta
925+ uses: docker/metadata-action@v5
926+ with:
927+ images: name/app
928+ -
929+ name: Build and push
930+ uses: docker/build-push-action@v5
931+ with:
932+ tags: ${{ steps.meta.outputs.tags }}
933+ annotations: ${{ steps.meta.outputs.annotations }}
934+ ` ` `
935+
936+ The same can be done with the [`bake-action`](https://github.com/docker/bake-action/) :
937+
938+ ` ` ` yaml
939+ -
940+ name: Docker meta
941+ uses: docker/metadata-action@v5
942+ with:
943+ images: name/app
944+ -
945+ name: Build
946+ uses: docker/bake-action@v3
947+ with:
948+ files: |
949+ ./docker-bake.hcl
950+ ${{ steps.meta.outputs.bake-file-tags }}
951+ ${{ steps.meta.outputs.bake-file-annotations }}
952+ targets: build
953+ ` ` `
954+
955+ If you want to set specific level(s) for your annotations, you can use the
956+ [`DOCKER_METADATA_ANNOTATIONS_LEVELS` environment variable](#environment-variables)
957+ with a comma separated list of levels (defaults to `manifest`) :
958+
959+ ` ` ` yaml
960+ -
961+ name: Docker meta
962+ uses: docker/metadata-action@v5
963+ with:
964+ images: name/app
965+ env:
966+ DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
967+ -
968+ name: Build and push
969+ uses: docker/build-push-action@v5
970+ with:
971+ tags: ${{ steps.meta.outputs.tags }}
972+ annotations: ${{ steps.meta.outputs.annotations }}
973+ ` ` `
974+
975+ More information about annotations in the [BuildKit documentation](https://github.com/moby/buildkit/blob/master/docs/annotations.md).
976+
907977# # Contributing
908978
909979Want to contribute? Awesome! You can find information about contributing to
0 commit comments