Skip to content

Commit a8a0da5

Browse files
committed
fix
1 parent 24bc24a commit a8a0da5

File tree

2 files changed

+32
-100
lines changed

2 files changed

+32
-100
lines changed

.github/workflows/docker-image-alpha.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
echo "VERSION=$VERSION" >> $GITHUB_ENV
4343
echo "Publishing version: $VERSION for ${{ matrix.arch }}"
4444
45+
- name: Normalize GHCR repository
46+
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
47+
4548
- name: Set up Docker Buildx
4649
uses: docker/setup-buildx-action@v3
4750

@@ -64,7 +67,7 @@ jobs:
6467
with:
6568
images: |
6669
calciumion/new-api
67-
ghcr.io/${{ github.repository }}
70+
ghcr.io/${{ env.GHCR_REPOSITORY }}
6871
6972
- name: Build & push single-arch (to both registries)
7073
uses: docker/build-push-action@v6
@@ -75,8 +78,8 @@ jobs:
7578
tags: |
7679
calciumion/new-api:alpha-${{ matrix.arch }}
7780
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
78-
ghcr.io/${{ github.repository }}:alpha-${{ matrix.arch }}
79-
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
81+
ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha-${{ matrix.arch }}
82+
ghcr.io/${{ env.GHCR_REPOSITORY }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
8083
labels: ${{ steps.meta.outputs.labels }}
8184
cache-from: type=gha
8285
cache-to: type=gha,mode=max
@@ -96,6 +99,9 @@ jobs:
9699
with:
97100
fetch-depth: 1
98101

102+
- name: Normalize GHCR repository
103+
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
104+
99105
- name: Determine alpha version
100106
id: version
101107
run: |
@@ -133,13 +139,13 @@ jobs:
133139
- name: Create & push manifest (GHCR - alpha)
134140
run: |
135141
docker buildx imagetools create \
136-
-t ghcr.io/${GITHUB_REPOSITORY}:alpha \
137-
ghcr.io/${GITHUB_REPOSITORY}:alpha-amd64 \
138-
ghcr.io/${GITHUB_REPOSITORY}:alpha-arm64
142+
-t ghcr.io/${GHCR_REPOSITORY}:alpha \
143+
ghcr.io/${GHCR_REPOSITORY}:alpha-amd64 \
144+
ghcr.io/${GHCR_REPOSITORY}:alpha-arm64
139145
140146
- name: Create & push manifest (GHCR - versioned alpha)
141147
run: |
142148
docker buildx imagetools create \
143-
-t ghcr.io/${GITHUB_REPOSITORY}:${VERSION} \
144-
ghcr.io/${GITHUB_REPOSITORY}:${VERSION}-amd64 \
145-
ghcr.io/${GITHUB_REPOSITORY}:${VERSION}-arm64
149+
-t ghcr.io/${GHCR_REPOSITORY}:${VERSION} \
150+
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-amd64 \
151+
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-arm64
Lines changed: 17 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
1-
name: Publish Docker image (Multi Registries, native amd64+arm64)
1+
name: Publish Docker image (Multi Registries)
22

33
on:
44
push:
55
tags:
66
- '*'
7-
87
jobs:
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

Comments
 (0)