|
18 | 18 | * [Outputs](#outputs-1) |
19 | 19 | * [Notes](#notes) |
20 | 20 | * [Runner mapping](#runner-mapping) |
| 21 | + * [Metadata templates](#metadata-templates) |
21 | 22 |
|
22 | 23 | ## Overview |
23 | 24 |
|
@@ -233,29 +234,6 @@ jobs: |
233 | 234 | | `meta-tags` | List | | [List of tags](https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input) as key-value pair attributes | |
234 | 235 | | `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` | |
235 | 236 |
|
236 | | -> [!TIP] |
237 | | -> When `output=image`, following inputs support Handlebars templates rendered |
238 | | -> from selected `docker/metadata-action` outputs: |
239 | | -> - `annotations` |
240 | | -> - `build-args` |
241 | | -> - `labels` |
242 | | -> |
243 | | -> The template context is exposed as `meta` with: |
244 | | -> - `meta.version` |
245 | | -> - `meta.tags` |
246 | | -> |
247 | | -> Example: |
248 | | -> ```yaml |
249 | | -> jobs: |
250 | | -> build: |
251 | | -> uses: docker/github-builder/.github/workflows/build.yml@v1 |
252 | | -> with: |
253 | | -> output: image |
254 | | -> build-args: | |
255 | | -> VERSION={{meta.version}} |
256 | | -> meta-images: name/app |
257 | | -> ``` |
258 | | - |
259 | 237 | ### Secrets |
260 | 238 |
|
261 | 239 | | Name | Default | Description | |
@@ -365,26 +343,6 @@ jobs: |
365 | 343 | | `meta-annotations` | List | | [List of custom annotations](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) | |
366 | 344 | | `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` | |
367 | 345 |
|
368 | | -> [!TIP] |
369 | | -> When `output=image`, the `set` input supports Handlebars templates rendered |
370 | | -> from selected `docker/metadata-action` outputs. |
371 | | -> |
372 | | -> The template context is exposed as `meta` with: |
373 | | -> - `meta.version` |
374 | | -> - `meta.tags` |
375 | | -> |
376 | | -> Example: |
377 | | -> ```yaml |
378 | | -> jobs: |
379 | | -> bake: |
380 | | -> uses: docker/github-builder/.github/workflows/bake.yml@v1 |
381 | | -> with: |
382 | | -> output: image |
383 | | -> set: | |
384 | | -> *.args.VERSION={{meta.version}} |
385 | | -> meta-images: name/app |
386 | | -> ``` |
387 | | - |
388 | 346 | ### Secrets |
389 | 347 |
|
390 | 348 | | Name | Default | Description | |
@@ -440,3 +398,36 @@ runner: | |
440 | 398 |
|
441 | 399 | For example, `linux` matches all Linux platforms, `linux/arm` matches variants |
442 | 400 | such as `linux/arm/v7`, and `linux/arm64` is separate from `linux/arm`. |
| 401 | + |
| 402 | +### Metadata templates |
| 403 | + |
| 404 | +When `output=image`, some inputs support Handlebars templates rendered from |
| 405 | +selected `docker/metadata-action` outputs. The template context is exposed as |
| 406 | +`meta` with `meta.version` and `meta.tags`. |
| 407 | + |
| 408 | +For the build workflow, the `annotations`, `build-args`, and `labels` inputs |
| 409 | +support metadata templates: |
| 410 | + |
| 411 | +```yaml |
| 412 | +jobs: |
| 413 | + build: |
| 414 | + uses: docker/github-builder/.github/workflows/build.yml@v1 |
| 415 | + with: |
| 416 | + output: image |
| 417 | + build-args: | |
| 418 | + VERSION={{meta.version}} |
| 419 | + meta-images: name/app |
| 420 | +``` |
| 421 | + |
| 422 | +For the bake workflow, the `set` input supports metadata templates: |
| 423 | + |
| 424 | +```yaml |
| 425 | +jobs: |
| 426 | + bake: |
| 427 | + uses: docker/github-builder/.github/workflows/bake.yml@v1 |
| 428 | + with: |
| 429 | + output: image |
| 430 | + set: | |
| 431 | + *.args.VERSION={{meta.version}} |
| 432 | + meta-images: name/app |
| 433 | +``` |
0 commit comments