Skip to content

Commit 4b07e78

Browse files
committed
Add GitHub Actions workflow to build run-gitmanager images
1 parent 2b72003 commit 4b07e78

3 files changed

Lines changed: 202 additions & 43 deletions

File tree

.github/workflows/build.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]*'
7+
8+
jobs:
9+
prepare:
10+
name: Determine base tag
11+
runs-on: ubuntu-24.04
12+
outputs:
13+
base_full_tag: ${{ steps.tags.outputs.base_full_tag }}
14+
15+
steps:
16+
- name: Determine base tag
17+
id: tags
18+
run: |
19+
ref="${GITHUB_REF_NAME}"
20+
if [[ "$ref" =~ ^v([0-9]+\.[0-9]+)\.[0-9]+$ ]]; then
21+
minor="${BASH_REMATCH[1]}"
22+
echo "base_full_tag=$minor" >> "$GITHUB_OUTPUT"
23+
else
24+
echo "base_full_tag=latest" >> "$GITHUB_OUTPUT"
25+
fi
26+
27+
build-base:
28+
name: Build base image (${{ matrix.platform }})
29+
runs-on: ${{ matrix.runner }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- platform: linux/amd64
35+
runner: ubuntu-24.04
36+
- platform: linux/arm64
37+
runner: ubuntu-24.04-arm
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Log in to Docker Hub
43+
uses: docker/login-action@v3
44+
with:
45+
username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
50+
51+
# Build and push platform-specific digest (no manifest tag yet)
52+
- name: Build and push by digest
53+
id: build
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
file: docker/Dockerfile
58+
platforms: ${{ matrix.platform }}
59+
push: true
60+
outputs: type=image,name=apluslms/run-gitmanager,push-by-digest=true,name-canonical=true
61+
62+
- name: Export digest
63+
run: |
64+
mkdir -p /tmp/digests
65+
digest="${{ steps.build.outputs.digest }}"
66+
touch "/tmp/digests/${digest#sha256:}"
67+
68+
- name: Upload digest artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: digest-base-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
72+
path: /tmp/digests/*
73+
retention-days: 1
74+
75+
merge-base:
76+
name: Merge base manifests
77+
runs-on: ubuntu-24.04
78+
needs: build-base
79+
80+
steps:
81+
- name: Download digests
82+
uses: actions/download-artifact@v4
83+
with:
84+
path: /tmp/digests
85+
pattern: digest-base-*
86+
merge-multiple: true
87+
88+
- name: Log in to Docker Hub
89+
uses: docker/login-action@v3
90+
with:
91+
username: ${{ secrets.DOCKERHUB_USERNAME }}
92+
password: ${{ secrets.DOCKERHUB_TOKEN }}
93+
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Determine tags
98+
id: meta
99+
uses: docker/metadata-action@v5
100+
with:
101+
images: apluslms/run-gitmanager
102+
tags: |
103+
type=raw,value=latest
104+
type=match,pattern=v(\d+\.\d+)\.\d+$,group=1
105+
106+
- name: Create and push multi-arch manifest
107+
working-directory: /tmp/digests
108+
run: |
109+
docker buildx imagetools create \
110+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
111+
$(printf 'apluslms/run-gitmanager@sha256:%s ' *)
112+
113+
build-huey:
114+
name: Build huey image (${{ matrix.platform }})
115+
runs-on: ${{ matrix.runner }}
116+
needs:
117+
- prepare
118+
- merge-base
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
include:
123+
- platform: linux/amd64
124+
runner: ubuntu-24.04
125+
- platform: linux/arm64
126+
runner: ubuntu-24.04-arm
127+
128+
steps:
129+
- uses: actions/checkout@v4
130+
131+
- name: Log in to Docker Hub
132+
uses: docker/login-action@v3
133+
with:
134+
username: ${{ secrets.DOCKERHUB_USERNAME }}
135+
password: ${{ secrets.DOCKERHUB_TOKEN }}
136+
137+
- name: Set up Docker Buildx
138+
uses: docker/setup-buildx-action@v3
139+
140+
# Build and push platform-specific digest (no manifest tag yet)
141+
- name: Build and push by digest
142+
id: build
143+
uses: docker/build-push-action@v6
144+
with:
145+
context: .
146+
file: docker/Dockerfile.huey
147+
platforms: ${{ matrix.platform }}
148+
push: true
149+
build-args: |
150+
FULL_TAG=${{ needs.prepare.outputs.base_full_tag }}
151+
outputs: type=image,name=apluslms/run-gitmanager,push-by-digest=true,name-canonical=true
152+
153+
- name: Export digest
154+
run: |
155+
mkdir -p /tmp/digests
156+
digest="${{ steps.build.outputs.digest }}"
157+
touch "/tmp/digests/${digest#sha256:}"
158+
159+
- name: Upload digest artifact
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: digest-huey-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
163+
path: /tmp/digests/*
164+
retention-days: 1
165+
166+
merge-huey:
167+
name: Merge huey manifests
168+
runs-on: ubuntu-24.04
169+
needs: build-huey
170+
171+
steps:
172+
- name: Download digests
173+
uses: actions/download-artifact@v4
174+
with:
175+
path: /tmp/digests
176+
pattern: digest-huey-*
177+
merge-multiple: true
178+
179+
- name: Log in to Docker Hub
180+
uses: docker/login-action@v3
181+
with:
182+
username: ${{ secrets.DOCKERHUB_USERNAME }}
183+
password: ${{ secrets.DOCKERHUB_TOKEN }}
184+
185+
- name: Set up Docker Buildx
186+
uses: docker/setup-buildx-action@v3
187+
188+
- name: Determine tags
189+
id: meta
190+
uses: docker/metadata-action@v5
191+
with:
192+
images: apluslms/run-gitmanager
193+
tags: |
194+
type=raw,value=huey-latest
195+
type=match,pattern=v(\d+\.\d+)\.\d+$,group=1,prefix=huey-
196+
197+
- name: Create and push multi-arch manifest
198+
working-directory: /tmp/digests
199+
run: |
200+
docker buildx imagetools create \
201+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
202+
$(printf 'apluslms/run-gitmanager@sha256:%s ' *)

docker/hooks/build

Lines changed: 0 additions & 40 deletions
This file was deleted.

docker/hooks/push

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)