Skip to content

Commit 9d6243d

Browse files
committed
feat(workflows): Use matrix build strategy for frontend and backend images
1 parent d79b1c7 commit 9d6243d

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed
Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
run-name: "Build and Release Web version ${{ github.ref_name }}"
2-
32
on:
43
push:
54
branches:
65
- web
76
workflow_dispatch:
87

98
env:
10-
FRONTEND_IMAGE: ghcr.io/dk10ws/slcm-frontend
11-
BACKEND_IMAGE: ghcr.io/dk10ws/slcm-backend
9+
REGISTRY: ghcr.io
10+
IMAGE_PREFIX: ghcr.io/dk10ws/slcm
1211

1312
jobs:
1413
build:
15-
name: Build & Release Web version
14+
name: Build ${{ matrix.service }} (${{ matrix.arch }})
1615
strategy:
1716
matrix:
17+
arch: [amd64, arm64]
18+
service: [frontend, backend]
1819
include:
1920
- arch: amd64
2021
runner: ubuntu-latest
2122
- arch: arm64
2223
runner: ubuntu-24.04-arm
2324
runs-on: ${{ matrix.runner }}
24-
2525
steps:
2626
- name: Checkout Repository
2727
uses: actions/checkout@v5
@@ -38,57 +38,39 @@ jobs:
3838
- name: Set up Docker Buildx
3939
uses: docker/setup-buildx-action@v3
4040

41-
- name: Build and Push frontend Docker Image
42-
uses: docker/build-push-action@v6
43-
with:
44-
context: frontend
45-
push: true
46-
platforms: linux/${{ matrix.arch }}
47-
tags: |
48-
${{ env.FRONTEND_IMAGE }}:latest-${{ matrix.arch }}
49-
${{ env.FRONTEND_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
50-
cache-from: type=gha
51-
cache-to: type=gha,mode=max
52-
53-
- name: Build and Push backend Docker Image
41+
- name: Build and Push ${{ matrix.service }} Docker Image
5442
uses: docker/build-push-action@v6
5543
with:
56-
context: backend
44+
context: ${{ matrix.service }}
5745
push: true
5846
platforms: linux/${{ matrix.arch }}
5947
tags: |
60-
${{ env.BACKEND_IMAGE }}:latest-${{ matrix.arch }}
61-
${{ env.BACKEND_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
62-
cache-from: type=gha
63-
cache-to: type=gha,mode=max
48+
${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:latest-${{ matrix.arch }}
49+
${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ github.sha }}-${{ matrix.arch }}
50+
cache-from: type=gha,scope=${{ matrix.service }}-${{ matrix.arch }}
51+
cache-to: type=gha,mode=max,scope=${{ matrix.service }}-${{ matrix.arch }}
6452

6553
merge-manifest:
6654
needs: build
67-
runs-on: ubuntu-latest
68-
55+
runs-on: ubuntu-slim
56+
strategy:
57+
matrix:
58+
service: [frontend, backend]
6959
steps:
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
7063
- name: Log in to GitHub Container Registry
7164
uses: docker/login-action@v3
7265
with:
7366
registry: ghcr.io
7467
username: ${{ github.actor }}
7568
password: ${{ secrets.GITHUB_TOKEN }}
7669

77-
- name: Set up Docker Buildx
78-
uses: docker/setup-buildx-action@v3
79-
80-
- name: Create multi-arch manifest for frontend
81-
run: |
82-
docker buildx imagetools create \
83-
-t ${{ env.FRONTEND_IMAGE }}:${{ github.sha }} \
84-
-t ${{ env.FRONTEND_IMAGE }}:latest \
85-
${{ env.FRONTEND_IMAGE }}:${{ github.sha }}-amd64 \
86-
${{ env.FRONTEND_IMAGE }}:${{ github.sha }}-arm64
87-
88-
- name: Create multi-arch manifest for backend
70+
- name: Create multi-arch manifest for ${{ matrix.service }}
8971
run: |
9072
docker buildx imagetools create \
91-
-t ${{ env.BACKEND_IMAGE }}:${{ github.sha }} \
92-
-t ${{ env.BACKEND_IMAGE }}:latest \
93-
${{ env.BACKEND_IMAGE }}:${{ github.sha }}-amd64 \
94-
${{ env.BACKEND_IMAGE }}:${{ github.sha }}-arm64
73+
-t ${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ github.sha }} \
74+
-t ${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:latest \
75+
${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ github.sha }}-amd64 \
76+
${{ env.IMAGE_PREFIX }}-${{ matrix.service }}:${{ github.sha }}-arm64

0 commit comments

Comments
 (0)