Skip to content

Commit 25b7366

Browse files
committed
chore: run docker builds in parallel
1 parent 89b5c03 commit 25b7366

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

.github/workflows/docker-publish.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ env:
1212
IMAGE_NAME: ${{ github.repository }}
1313

1414
jobs:
15-
build-and-push:
16-
name: Build and Push Docker Image
15+
build:
16+
name: Build Docker Image (${{ matrix.platform }})
1717
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
platform: [linux/amd64, linux/arm64]
1821
permissions:
19-
contents: write
22+
contents: read
2023
packages: write
2124
steps:
2225
- name: Checkout repository
@@ -32,21 +35,52 @@ jobs:
3235
username: ${{ github.actor }}
3336
password: ${{ secrets.GITHUB_TOKEN }}
3437

38+
- name: Sanitize platform for tag
39+
id: platform
40+
run: |
41+
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | tr '/' '-')
42+
echo "tag=$PLATFORM_TAG" >> $GITHUB_OUTPUT
43+
3544
- name: Build and push Docker image
36-
id: docker_build
3745
uses: docker/build-push-action@v5
3846
with:
3947
context: .
4048
push: true
4149
tags: |
42-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}
43-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
50+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-${{ steps.platform.outputs.tag }}
4451
labels: |
4552
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
4653
org.opencontainers.image.revision=${{ github.sha }}
4754
cache-from: type=gha
4855
cache-to: type=gha,mode=max
49-
platforms: linux/amd64,linux/arm64
56+
platforms: ${{ matrix.platform }}
57+
provenance: false
58+
59+
merge:
60+
name: Create Multi-Arch Manifest
61+
runs-on: ubuntu-latest
62+
needs: build
63+
permissions:
64+
contents: write
65+
packages: write
66+
steps:
67+
- name: Set up Docker Buildx
68+
uses: docker/setup-buildx-action@v3
69+
70+
- name: Log in to Container Registry
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ${{ env.REGISTRY }}
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Create and push multi-arch manifest
78+
run: |
79+
docker buildx imagetools create \
80+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }} \
81+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
82+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-linux-amd64 \
83+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-linux-arm64
5084
5185
- name: Add Docker image info to release
5286
uses: actions/github-script@v7

0 commit comments

Comments
 (0)