Skip to content

Commit 2cc547d

Browse files
ptr727claude
andcommitted
Build the multi-arch image only on main, amd64 elsewhere
The Docker build dominates Actions minutes and arm64 is emulated on the amd64 runner, so build linux/amd64,linux/arm64 only on a full main publish; smoke and develop build linux/amd64 only. A job-level env.PLATFORMS drives buildx and build-push, and QEMU is set up only when arm64 is in the platform set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ec47934 commit 2cc547d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/build-docker-task.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build Docker image task
22

3-
# Builds the multi-arch image (linux/amd64,arm64) and, on a main publish, pushes it plus the Docker Hub overview.
3+
# Builds the image (multi-arch on main, amd64 on develop/smoke) and, on a main publish, pushes it plus the Docker Hub overview.
44
# Branch drives config and tags: main => Release/`latest`, else Debug/`develop`, plus the `:SemVer2` tag. Smoke builds
55
# amd64 only and never pushes; registry buildcache is branch-scoped. The orchestrator passes `branch` explicitly
66
# (the publisher builds one branch per run - the trigger ref - and smoke passes github.ref_name).
@@ -46,6 +46,9 @@ jobs:
4646
build-docker:
4747
name: Build Docker image job
4848
runs-on: ubuntu-latest
49+
env:
50+
# Multi-arch (amd64+arm64) only on a full main publish; smoke and develop build amd64 only.
51+
PLATFORMS: ${{ (!inputs.smoke && inputs.branch == 'main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
4952

5053
steps:
5154

@@ -54,17 +57,17 @@ jobs:
5457
with:
5558
ref: ${{ inputs.ref }}
5659

57-
# QEMU only emulates arm64; smoke is amd64-only, so skip it to save setup cost.
60+
# arm64 is non-native on the amd64 runner, so install its QEMU emulator only when the build includes it.
5861
- name: Setup QEMU step
59-
if: ${{ !inputs.smoke }}
62+
if: ${{ contains(env.PLATFORMS, 'arm64') }}
6063
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
6164
with:
62-
platforms: linux/amd64,linux/arm64
65+
platforms: arm64
6366

6467
- name: Setup Buildx step
6568
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
6669
with:
67-
platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
70+
platforms: ${{ env.PLATFORMS }}
6871

6972
# Always login (even on smoke) for higher pull/cache-read rate limits; the credentials are in both the
7073
# Actions and Dependabot secret stores so a Dependabot push CI run can log in too. Forks cannot push here.
@@ -83,7 +86,7 @@ jobs:
8386
tags: |
8487
docker.io/ptr727/plexcleaner:${{ inputs.branch == 'main' && 'latest' || 'develop' }}
8588
docker.io/ptr727/plexcleaner:${{ inputs.semver2 }}
86-
platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
89+
platforms: ${{ env.PLATFORMS }}
8790
# Read both branches' caches (near-identical layers), write only this branch's tag and only when pushing.
8891
# mode=max caches the builder publish; ignore-error keeps a cache hiccup from failing a publish.
8992
cache-from: |

0 commit comments

Comments
 (0)