Skip to content

Commit d17d52f

Browse files
committed
feat(workflow): new docker image process
1 parent 484c6b2 commit d17d52f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.github/workflows/docker-publish-dev.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55

66
env:
7-
REGISTRY_IMAGE_BASE: estoesmoises/stackoverflow-backstage-demo
7+
REGISTRY_IMAGE_BASE: stackoverflowdocker/stackoverflow-backstage-demo
88
IMAGE_TAG: test
99

1010
jobs:
@@ -25,6 +25,12 @@ jobs:
2525
platform=${{ matrix.platform }}
2626
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
2727
28+
- name: Docker meta
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: ${{ env.REGISTRY_IMAGE }}
33+
2834
- name: Login to Docker Hub
2935
uses: docker/login-action@v3
3036
with:
@@ -43,7 +49,8 @@ jobs:
4349
with:
4450
context: .
4551
platforms: ${{ matrix.platform }}
46-
outputs: type=image,push-by-digest=true,name=${{ env.REGISTRY_IMAGE_BASE }},push=true
52+
labels: ${{ steps.meta.outputs.labels }}
53+
outputs: type=image,push-by-digest=true,name=${{ env.REGISTRY_IMAGE }},push=true
4754

4855
- name: Export digest
4956
run: |
@@ -80,12 +87,22 @@ jobs:
8087
- name: Set up Docker Buildx
8188
uses: docker/setup-buildx-action@v3
8289

83-
- name: Create manifest list and push with test tag
90+
- name: Docker meta
91+
id: meta
92+
uses: docker/metadata-action@v5
93+
with:
94+
images: ${{ env.REGISTRY_IMAGE }}
95+
tags: |
96+
type=semver,pattern={{version}}
97+
type=semver,pattern={{major}}.{{minor}}
98+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
99+
100+
- name: Create manifest list and push
84101
working-directory: ${{ runner.temp }}/digests
85102
run: |
86-
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE_BASE }}:${{ env.IMAGE_TAG }} \
87-
$(printf '${{ env.REGISTRY_IMAGE_BASE }}@sha256:%s ' *)
103+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
104+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
88105
89106
- name: Inspect image
90107
run: |
91-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE_BASE }}:${{ env.IMAGE_TAG }}
108+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)