diff --git a/.github/workflows/.test-build.yml b/.github/workflows/.test-build.yml index f824b8fb..547ae72a 100644 --- a/.github/workflows/.test-build.yml +++ b/.github/workflows/.test-build.yml @@ -589,9 +589,9 @@ jobs: packages: write with: annotations: | - io.github.docker.github-builder.test-index-annotation=build-${{ github.run_id }} + io.github.docker.github-builder.test-direct-index-annotation={{meta.version}} labels: | - io.github.docker.github-builder.test-label=build-${{ github.run_id }} + io.github.docker.github-builder.test-direct-label=build-{{meta.version}} build-args: | VERSION={{meta.version}} file: test/hello.Dockerfile @@ -604,6 +604,10 @@ jobs: meta-images: ghcr.io/docker/github-builder-test meta-tags: | type=raw,value=build-index-annotations-${{ github.run_id }} + meta-labels: | + io.github.docker.github-builder.test-meta-label=build-${{ github.run_id }} + meta-annotations: | + io.github.docker.github-builder.test-meta-index-annotation=build-${{ github.run_id }} secrets: registry-auths: | - registry: ghcr.io diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e1296c5..c7fdb43a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ on: default: 0 annotations: type: string - description: "List of annotations to set to the image (for image output)" + description: "List of annotations to set to the image" required: false build-args: type: string @@ -78,7 +78,7 @@ on: required: false labels: type: string - description: "List of labels for an image (for image output)" + description: "List of labels for an image" required: false output: type: string @@ -134,6 +134,14 @@ on: type: string description: "List of tags as key-value pair attributes" required: false + meta-labels: + type: string + description: "List of custom labels" + required: false + meta-annotations: + type: string + description: "List of custom annotations" + required: false meta-flavor: type: string description: "Flavor defines a global behavior for meta-tags" @@ -558,6 +566,8 @@ jobs: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} flavor: ${{ inputs.meta-flavor }} + labels: ${{ inputs.meta-labels }} + annotations: ${{ inputs.meta-annotations }} - name: Set up QEMU uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 @@ -1028,6 +1038,8 @@ jobs: images: ${{ needs.prepare.outputs.metaImages }} tags: ${{ inputs.meta-tags }} flavor: ${{ inputs.meta-flavor }} + labels: ${{ inputs.meta-labels }} + annotations: ${{ inputs.meta-annotations }} - name: Login to registry if: ${{ inputs.push && inputs.output == 'image' }} diff --git a/README.md b/README.md index 8231fb15..c8894f5e 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,8 @@ jobs: | `set-meta-labels` | Bool | `false` | Append OCI Image Format Specification labels generated by `docker/metadata-action` | | `meta-images` | List | | [List of images](https://github.com/docker/metadata-action?tab=readme-ov-file#images-input) to use as base name for tags (required for image output) | | `meta-tags` | List | | [List of tags](https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input) as key-value pair attributes | +| `meta-labels` | List | | [List of custom labels](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) | +| `meta-annotations` | List | | [List of custom annotations](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) | | `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` | ### Secrets @@ -458,3 +460,10 @@ jobs: *.args.VERSION={{meta.version}} meta-images: name/app ``` + +> [!NOTE] +> The `meta-labels` and `meta-annotations` inputs are passed to +> `docker/metadata-action`, so their templates follow `docker/metadata-action` +> behavior. Enable `set-meta-labels` or `set-meta-annotations` to apply those +> generated values to the image. In the build workflow, generated values are +> appended to any `labels` or `annotations` already set.