1- name : Publish Docker image (Multi Registries, native amd64+arm64 )
1+ name : Publish Docker image (Multi Registries)
22
33on :
44 push :
55 tags :
66 - ' *'
7-
87jobs :
9- build_single_arch :
10- name : Build & push (${{ matrix.arch }}) [native]
11- strategy :
12- fail-fast : false
13- matrix :
14- include :
15- - arch : amd64
16- platform : linux/amd64
17- runner : ubuntu-latest
18- - arch : arm64
19- platform : linux/arm64
20- runner : ubuntu-24.04-arm64
21- runs-on : ${{ matrix.runner }}
22-
8+ push_to_registries :
9+ name : Push Docker image to multiple registries
10+ runs-on : ubuntu-latest
2311 permissions :
2412 packages : write
2513 contents : read
26-
2714 steps :
28- - name : Check out (shallow)
15+ - name : Check out the repo
2916 uses : actions/checkout@v4
30- with :
31- fetch-depth : 1
3217
33- - name : Resolve tag & write VERSION
18+ - name : Save version info
3419 run : |
35- git fetch --tags --force --depth=1
36- echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
37- echo "$TAG" > VERSION
38- echo "Building tag: $TAG for ${{ matrix.arch }}"
20+ git describe --tags > VERSION
21+
22+ - name : Set up QEMU
23+ uses : docker/setup-qemu-action@v3
3924
4025 - name : Set up Docker Buildx
4126 uses : docker/setup-buildx-action@v3
@@ -46,85 +31,26 @@ jobs:
4631 username : ${{ secrets.DOCKERHUB_USERNAME }}
4732 password : ${{ secrets.DOCKERHUB_TOKEN }}
4833
49- - name : Log in to GHCR
34+ - name : Log in to the Container registry
5035 uses : docker/login-action@v3
5136 with :
5237 registry : ghcr.io
5338 username : ${{ github.actor }}
5439 password : ${{ secrets.GITHUB_TOKEN }}
5540
56- - name : Extract metadata (labels)
41+ - name : Extract metadata (tags, labels) for Docker
5742 id : meta
5843 uses : docker/metadata-action@v5
5944 with :
6045 images : |
6146 calciumion/new-api
6247 ghcr.io/${{ github.repository }}
6348
64- - name : Build & push single-arch (to both registries)
65- uses : docker/build-push-action@v6
49+ - name : Build and push Docker images
50+ uses : docker/build-push-action@v5
6651 with :
6752 context : .
68- platforms : ${{ matrix.platform }}
53+ platforms : linux/amd64,linux/arm64
6954 push : true
70- tags : |
71- calciumion/new-api:${{ env.TAG }}-${{ matrix.arch }}
72- calciumion/new-api:latest-${{ matrix.arch }}
73- ghcr.io/${{ github.repository }}:${{ env.TAG }}-${{ matrix.arch }}
74- ghcr.io/${{ github.repository }}:latest-${{ matrix.arch }}
75- labels : ${{ steps.meta.outputs.labels }}
76- cache-from : type=gha
77- cache-to : type=gha,mode=max
78- provenance : false
79- sbom : false
80-
81- create_manifests :
82- name : Create multi-arch manifests (Docker Hub + GHCR)
83- needs : [build_single_arch]
84- runs-on : ubuntu-latest
85- if : startsWith(github.ref, 'refs/tags/')
86- steps :
87- - name : Extract tag
88- run : echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
89-
90- - name : Log in to Docker Hub
91- uses : docker/login-action@v3
92- with :
93- username : ${{ secrets.DOCKERHUB_USERNAME }}
94- password : ${{ secrets.DOCKERHUB_TOKEN }}
95-
96- - name : Create & push manifest (Docker Hub - version)
97- run : |
98- docker buildx imagetools create \
99- -t calciumion/new-api:${TAG} \
100- calciumion/new-api:${TAG}-amd64 \
101- calciumion/new-api:${TAG}-arm64
102-
103- - name : Create & push manifest (Docker Hub - latest)
104- run : |
105- docker buildx imagetools create \
106- -t calciumion/new-api:latest \
107- calciumion/new-api:latest-amd64 \
108- calciumion/new-api:latest-arm64
109-
110- # ---- GHCR ----
111- - name : Log in to GHCR
112- uses : docker/login-action@v3
113- with :
114- registry : ghcr.io
115- username : ${{ github.actor }}
116- password : ${{ secrets.GITHUB_TOKEN }}
117-
118- - name : Create & push manifest (GHCR - version)
119- run : |
120- docker buildx imagetools create \
121- -t ghcr.io/${GITHUB_REPOSITORY}:${TAG} \
122- ghcr.io/${GITHUB_REPOSITORY}:${TAG}-amd64 \
123- ghcr.io/${GITHUB_REPOSITORY}:${TAG}-arm64
124-
125- - name : Create & push manifest (GHCR - latest)
126- run : |
127- docker buildx imagetools create \
128- -t ghcr.io/${GITHUB_REPOSITORY}:latest \
129- ghcr.io/${GITHUB_REPOSITORY}:latest-amd64 \
130- ghcr.io/${GITHUB_REPOSITORY}:latest-arm64
55+ tags : ${{ steps.meta.outputs.tags }}
56+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments