Skip to content

Commit add59b5

Browse files
seefs001Sacode
authored andcommitted
Alpha CI (QuantumNous#2011)
1 parent 5875b58 commit add59b5

File tree

2 files changed

+113
-22
lines changed

2 files changed

+113
-22
lines changed

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

Lines changed: 108 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,141 @@ on:
1111
required: false
1212

1313
jobs:
14-
push_to_registries:
15-
name: Push Docker image to multiple registries
16-
runs-on: ubuntu-latest
14+
build_single_arch:
15+
name: Build & push (${{ matrix.arch }}) [native]
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- arch: amd64
21+
platform: linux/amd64
22+
runner: ubuntu-latest
23+
- arch: arm64
24+
platform: linux/arm64
25+
runner: ubuntu-24.04-arm
26+
runs-on: ${{ matrix.runner }}
1727
permissions:
1828
packages: write
1929
contents: read
2030
steps:
21-
- name: Check out the repo
31+
- name: Check out (shallow)
2232
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
2335

24-
- name: Save version info
36+
- name: Determine alpha version
37+
id: version
2538
run: |
26-
echo "alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" > VERSION
39+
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
40+
echo "$VERSION" > VERSION
41+
echo "value=$VERSION" >> $GITHUB_OUTPUT
42+
echo "VERSION=$VERSION" >> $GITHUB_ENV
43+
echo "Publishing version: $VERSION for ${{ matrix.arch }}"
44+
45+
- name: Normalize GHCR repository
46+
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
2750

2851
- name: Log in to Docker Hub
2952
uses: docker/login-action@v3
3053
with:
3154
username: ${{ secrets.DOCKERHUB_USERNAME }}
3255
password: ${{ secrets.DOCKERHUB_TOKEN }}
3356

34-
- name: Log in to the Container registry
57+
- name: Log in to GHCR
3558
uses: docker/login-action@v3
3659
with:
3760
registry: ghcr.io
3861
username: ${{ github.actor }}
3962
password: ${{ secrets.GITHUB_TOKEN }}
4063

41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v3
43-
44-
- name: Extract metadata (tags, labels) for Docker
64+
- name: Extract metadata (labels)
4565
id: meta
4666
uses: docker/metadata-action@v5
4767
with:
4868
images: |
4969
calciumion/new-api
50-
ghcr.io/${{ github.repository }}
51-
tags: |
52-
type=raw,value=alpha
53-
type=raw,value=alpha-{{date 'YYYYMMDD'}}-{{sha}}
70+
ghcr.io/${{ env.GHCR_REPOSITORY }}
5471
55-
- name: Build and push Docker images
56-
uses: docker/build-push-action@v5
72+
- name: Build & push single-arch (to both registries)
73+
uses: docker/build-push-action@v6
5774
with:
5875
context: .
59-
platforms: linux/amd64,linux/arm64
76+
platforms: ${{ matrix.platform }}
6077
push: true
61-
tags: ${{ steps.meta.outputs.tags }}
78+
tags: |
79+
calciumion/new-api:alpha-${{ matrix.arch }}
80+
calciumion/new-api:${{ 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 }}
6283
labels: ${{ steps.meta.outputs.labels }}
84+
cache-from: type=gha
85+
cache-to: type=gha,mode=max
86+
provenance: false
87+
sbom: false
88+
89+
create_manifests:
90+
name: Create multi-arch manifests (Docker Hub + GHCR)
91+
needs: [build_single_arch]
92+
runs-on: ubuntu-latest
93+
permissions:
94+
packages: write
95+
contents: read
96+
steps:
97+
- name: Check out (shallow)
98+
uses: actions/checkout@v4
99+
with:
100+
fetch-depth: 1
101+
102+
- name: Normalize GHCR repository
103+
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
104+
105+
- name: Determine alpha version
106+
id: version
107+
run: |
108+
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
109+
echo "value=$VERSION" >> $GITHUB_OUTPUT
110+
echo "VERSION=$VERSION" >> $GITHUB_ENV
111+
112+
- name: Log in to Docker Hub
113+
uses: docker/login-action@v3
114+
with:
115+
username: ${{ secrets.DOCKERHUB_USERNAME }}
116+
password: ${{ secrets.DOCKERHUB_TOKEN }}
117+
118+
- name: Create & push manifest (Docker Hub - alpha)
119+
run: |
120+
docker buildx imagetools create \
121+
-t calciumion/new-api:alpha \
122+
calciumion/new-api:alpha-amd64 \
123+
calciumion/new-api:alpha-arm64
124+
125+
- name: Create & push manifest (Docker Hub - versioned alpha)
126+
run: |
127+
docker buildx imagetools create \
128+
-t calciumion/new-api:${VERSION} \
129+
calciumion/new-api:${VERSION}-amd64 \
130+
calciumion/new-api:${VERSION}-arm64
131+
132+
- name: Log in to GHCR
133+
uses: docker/login-action@v3
134+
with:
135+
registry: ghcr.io
136+
username: ${{ github.actor }}
137+
password: ${{ secrets.GITHUB_TOKEN }}
138+
139+
- name: Create & push manifest (GHCR - alpha)
140+
run: |
141+
docker buildx imagetools create \
142+
-t ghcr.io/${GHCR_REPOSITORY}:alpha \
143+
ghcr.io/${GHCR_REPOSITORY}:alpha-amd64 \
144+
ghcr.io/${GHCR_REPOSITORY}:alpha-arm64
145+
146+
- name: Create & push manifest (GHCR - versioned alpha)
147+
run: |
148+
docker buildx imagetools create \
149+
-t ghcr.io/${GHCR_REPOSITORY}:${VERSION} \
150+
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-amd64 \
151+
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-arm64

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ COPY ./VERSION .
99
RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
1010

1111
FROM golang:alpine AS builder2
12+
ENV GO111MODULE=on CGO_ENABLED=0
13+
14+
ARG TARGETOS
15+
ARG TARGETARCH
16+
ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
1217

13-
ENV GO111MODULE=on \
14-
CGO_ENABLED=0 \
15-
GOOS=linux
1618

1719
WORKDIR /build
1820

0 commit comments

Comments
 (0)