From f6e979f52d4a80d579f2f78b49b612b59d32033b Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Fri, 23 Oct 2026 21:41:04 +0800 Subject: [PATCH] Fix(ci): generate Docker image labels with metadata-action Multi-line release notes in the labels input split into one label per line and an empty line aborted buildx. Labels now come from docker/metadata-action with the version pinned to RELEASE_VERSION, and version inputs reach the shell through env instead of interpolation. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docker-image.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e0500ffc..fafa30d1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -46,17 +46,27 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Get the version and release notes + - name: Get the version if: github.event_name == 'release' - run: | - printf "RELEASE_VERSION=%s\n" "${{ github.event.release.tag_name }}" >> $GITHUB_ENV - printf "RELEASE_NOTES<> $GITHUB_ENV + env: + TAG_NAME: ${{ github.event.release.tag_name }} + run: echo "RELEASE_VERSION=$TAG_NAME" >> "$GITHUB_ENV" - name: Set version for manual dispatch if: github.event_name == 'workflow_dispatch' - run: | - echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV - echo "RELEASE_NOTES=Manually triggered build" >> $GITHUB_ENV + env: + DISPATCH_VERSION: ${{ github.event.inputs.version }} + run: echo "RELEASE_VERSION=$DISPATCH_VERSION" >> "$GITHUB_ENV" + + # OCI labels (title / description / source / revision / …) from the repo; + # tags stay hand-written below. A manual dispatch runs on `main`, so the + # version label is pinned to RELEASE_VERSION. + - name: Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + labels: | + org.opencontainers.image.version=${{ env.RELEASE_VERSION }} - name: Build and Push Docker Image uses: docker/build-push-action@v7 @@ -67,7 +77,5 @@ jobs: jason5ng32/myip:${{ env.RELEASE_VERSION }} ghcr.io/${{ github.repository_owner }}/myip:latest ghcr.io/${{ github.repository_owner }}/myip:${{ env.RELEASE_VERSION }} - labels: | - org.opencontainers.image.version=${{ env.RELEASE_VERSION }} - org.opencontainers.image.description=${{ env.RELEASE_NOTES }} + labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64