48
48
* [ Major version zero] ( #major-version-zero )
49
49
* [ JSON output object] ( #json-output-object )
50
50
* [ Overwrite labels] ( #overwrite-labels )
51
+ * [ Annotations] ( #annotations )
51
52
* [ Contributing] ( #contributing )
52
53
53
54
## Usage
@@ -307,23 +308,27 @@ The following inputs can be used as `step.with` keys:
307
308
308
309
The following outputs are available :
309
310
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) |
318
321
319
322
Alternatively, each output is also exported as an environment variable :
320
323
321
324
* `DOCKER_METADATA_OUTPUT_VERSION`
322
325
* `DOCKER_METADATA_OUTPUT_TAGS`
323
326
* `DOCKER_METADATA_OUTPUT_LABELS`
327
+ * `DOCKER_METADATA_OUTPUT_ANNOTATIONS`
324
328
* `DOCKER_METADATA_OUTPUT_JSON`
325
329
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS`
326
330
* `DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS`
331
+ * `DOCKER_METADATA_OUTPUT_BAKE_FILE_ANNOTATIONS`
327
332
328
333
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/) :
329
334
@@ -336,9 +341,10 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
336
341
337
342
# ## environment variables
338
343
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`) |
342
348
343
349
# # `context` input
344
350
@@ -904,6 +910,70 @@ labels generated are not suitable, you can overwrite them like this:
904
910
org.opencontainers.image.vendor=MyCompany
905
911
` ` `
906
912
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
+
907
977
# # Contributing
908
978
909
979
Want to contribute? Awesome! You can find information about contributing to
0 commit comments