Skip to content

Commit 1b56dc5

Browse files
committed
ci: publish multi-arch Docker images to GHCR on release
1 parent 4a4b23e commit 1b56dc5

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish Docker Images
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
name: Build ${{ matrix.service }} (${{ matrix.platform }})
10+
runs-on: blacksmith-4vcpu-ubuntu-2404
11+
permissions:
12+
contents: read
13+
packages: write
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
service: [api, basket, links, uptime]
18+
platform: [linux/amd64, linux/arm64]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: docker/setup-qemu-action@v3
24+
if: matrix.platform != 'linux/amd64'
25+
26+
- uses: docker/setup-buildx-action@v3
27+
28+
- uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract arch slug
35+
id: platform
36+
run: echo "arch=${PLATFORM##*/}" >> "$GITHUB_OUTPUT"
37+
env:
38+
PLATFORM: ${{ matrix.platform }}
39+
40+
- uses: docker/build-push-action@v6
41+
with:
42+
context: .
43+
file: ${{ matrix.service }}.Dockerfile
44+
push: true
45+
platforms: ${{ matrix.platform }}
46+
provenance: false
47+
tags: ghcr.io/databuddy-analytics/databuddy-${{ matrix.service }}:${{ github.event.release.tag_name }}-${{ steps.platform.outputs.arch }}
48+
cache-from: type=gha,scope=${{ matrix.service }}-${{ steps.platform.outputs.arch }}
49+
cache-to: type=gha,mode=max,scope=${{ matrix.service }}-${{ steps.platform.outputs.arch }}
50+
51+
manifest:
52+
name: Publish ${{ matrix.service }} manifest
53+
needs: build
54+
runs-on: blacksmith-4vcpu-ubuntu-2404
55+
permissions:
56+
packages: write
57+
strategy:
58+
matrix:
59+
service: [api, basket, links, uptime]
60+
61+
steps:
62+
- uses: docker/login-action@v3
63+
with:
64+
registry: ghcr.ioso i
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Create multi-arch manifest
69+
run: |
70+
IMAGE="ghcr.io/databuddy-analytics/databuddy-${{ matrix.service }}"
71+
TAG="${{ github.event.release.tag_name }}"
72+
73+
docker buildx imagetools create \
74+
--tag "$IMAGE:$TAG" \
75+
--tag "$IMAGE:latest" \
76+
"$IMAGE:$TAG-amd64" \
77+
"$IMAGE:$TAG-arm64"

0 commit comments

Comments
 (0)