From 863dbd5012a7688fd0a12d219f4446109c2e9787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= <37316281+yanhao98@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:30:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20docker/metadata-action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 9 +++++++-- docker-build-push/action.yml | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10a9d21..9f44179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,12 @@ jobs: build_push: false build_load: true build_tags: image-test + metadata_images: | + docker.io/murielmay67761/docker-example + metadata_tags: | + type=raw,value=latest - name: Check Docker image run: | - set -x - docker run --rm image-test:latest whoami \ No newline at end of file + set -x; + # docker run --rm image-test:latest whoami + docker images; diff --git a/docker-build-push/action.yml b/docker-build-push/action.yml index 1b101ed..2406f76 100644 --- a/docker-build-push/action.yml +++ b/docker-build-push/action.yml @@ -31,8 +31,11 @@ inputs: description: "是否加载 Docker 镜像" default: "false" required: false - build_tags: - description: "Docker 镜像标签" + metadata_images: + description: "docker/metadata-action 的 images 参数" + required: false + metadata_tags: + description: "docker/metadata-action 的 tags 参数" required: false runs: using: "composite" @@ -41,6 +44,12 @@ runs: with: filter: blob:none show-progress: false + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.metadata_images }} + tags: ${{ inputs.metadata_tags }} - name: Login to DockerHub uses: docker/login-action@v3 with: @@ -59,9 +68,9 @@ runs: platforms: ${{ inputs.build_platforms }} push: ${{ inputs.build_push }} load: ${{ inputs.build_load }} - tags: ${{ inputs.build_tags }} + tags: ${{ steps.meta.outputs.tags }} # labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file + # cache-to: type=local,dest=/tmp/.buildx-cache