测试 docker-build-push 的 imageid

This commit is contained in:
严浩
2024-10-09 09:37:57 +08:00
committed by GitHub
parent 863dbd5012
commit 6db6f75e58
2 changed files with 10 additions and 4 deletions

View File

@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: yanhao98/composite-actions/docker-build-push@main - uses: yanhao98/composite-actions/docker-build-push@main
id: docker-build-push
with: with:
login_username: ${{ secrets.DOCKERHUB_USERNAME }} login_username: ${{ secrets.DOCKERHUB_USERNAME }}
login_password: ${{ secrets.DOCKERHUB_TOKEN }} login_password: ${{ secrets.DOCKERHUB_TOKEN }}
@ -26,7 +27,6 @@ jobs:
build_platforms: linux/amd64 build_platforms: linux/amd64
build_push: false build_push: false
build_load: true build_load: true
build_tags: image-test
metadata_images: | metadata_images: |
docker.io/murielmay67761/docker-example docker.io/murielmay67761/docker-example
metadata_tags: | metadata_tags: |
@ -35,4 +35,5 @@ jobs:
run: | run: |
set -x; set -x;
# docker run --rm image-test:latest whoami # docker run --rm image-test:latest whoami
docker images; # docker images;
docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami

View File

@ -37,6 +37,10 @@ inputs:
metadata_tags: metadata_tags:
description: "docker/metadata-action 的 tags 参数" description: "docker/metadata-action 的 tags 参数"
required: false required: false
outputs:
imageid:
description: "Docker 镜像 ID"
value: ${{ steps.build.outputs.imageid }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
@ -61,7 +65,8 @@ runs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 id: build
uses: docker/build-push-action@v6 # https://github.com/docker/build-push-action
with: with:
file: ${{ inputs.build_file }} file: ${{ inputs.build_file }}
context: ${{ inputs.build_context }} context: ${{ inputs.build_context }}
@ -69,7 +74,7 @@ runs:
push: ${{ inputs.build_push }} push: ${{ inputs.build_push }}
load: ${{ inputs.build_load }} load: ${{ inputs.build_load }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
# cache-from: type=local,src=/tmp/.buildx-cache # cache-from: type=local,src=/tmp/.buildx-cache