Skip to content

Commit 97e96f2

Browse files
Pijukatelclaude
andauthored
Fix the release workflow's cache scope and branch selection (#37)
Two fixes to the release workflow #36 added. No new functionality — `Dockerfile` and the multi-arch build itself are untouched. ## The multi-platform cache scope was invalid ```yaml cache-from: type=gha,scope=release-${{ inputs.platforms }} ``` expanded to `type=gha,scope=release-linux/amd64,linux/arm64`. A `type=gha` value is itself a comma-separated key=value list, so the comma inside the platform list terminated `scope` and buildx read the leftover `linux/arm64` as a bare key: ``` ERROR: invalid value linux/arm64 ``` That killed the run before any build step, so **any dispatch with the default multi-platform list failed**. Only a single-platform run (no comma) got through. Both cache flags now use one shared `release` scope. The per-platform-set keying it replaces wasn't worth having: GHA cache scopes are separate namespaces, so sharing one lets a single-platform run reuse layers a multi-arch run already cached instead of starting cold. ## The `branch` input silently overrode the branch you picked There were two branch selectors, and the one you didn't touch won. **Use workflow from** chose which `release.yml` ran; the `branch` input chose what got checked out and tagged — and it defaulted to `master`. Dispatching from a feature branch and leaving the input alone therefore ran that branch's workflow against master's tree and pushed `master-<sha>`, `master`, `latest`. The input is gone. `actions/checkout` now takes no `ref:` at all, so it uses the dispatch commit, and the tag slug comes from `github.ref_name`. One branch picker, and no way for the built ref to disagree with it. Remaining inputs: `image`, `extra_tag`, `latest`, `platforms`. ## README Updated to match: **Use workflow from** is the only branch to choose, and the `/`-to-`-` tag slugification is now stated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01TzoV12kHAHm6EFNmUfZedq --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 619314e commit 97e96f2

2 files changed

Lines changed: 26 additions & 22 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: Release Docker image
22

3-
# Manual-only: pick a branch (or any ref - tag/SHA works too) and this builds the runtime image for
4-
# every platform in `platforms` and pushes it to Docker Hub as one multi-arch manifest per tag, so a
5-
# single tag serves x86_64 Linux/Windows-WSL2/Intel Mac and arm64 (Apple Silicon, Ampere) alike.
3+
# Manual-only: builds the runtime image for every platform in `platforms` and pushes it to Docker Hub
4+
# as one multi-arch manifest per tag, so a single tag serves x86_64 Linux/Windows-WSL2/Intel Mac and
5+
# arm64 (Apple Silicon, Ampere) alike.
6+
#
7+
# It always builds the branch it was dispatched from ("Use workflow from") - there is no ref input, so
8+
# there is no second branch to keep in sync with the one you picked.
69
on:
710
workflow_dispatch:
811
inputs:
9-
branch:
10-
description: Branch (or tag/SHA) to build the image from
11-
required: true
12-
default: master
1312
image:
1413
description: Docker Hub repository to push to
1514
required: true
@@ -34,9 +33,9 @@ jobs:
3433
runs-on: ubuntu-latest
3534
timeout-minutes: 60
3635
steps:
36+
# No `ref:` - checkout defaults to the commit the workflow was dispatched from, which is
37+
# exactly the branch picked in "Use workflow from".
3738
- uses: actions/checkout@v4
38-
with:
39-
ref: ${{ inputs.branch }}
4039

4140
# Fail here rather than three slow build steps later, with the fix named.
4241
- name: Check Docker Hub credentials are configured
@@ -57,7 +56,7 @@ jobs:
5756
id: tags
5857
env:
5958
IMAGE: ${{ inputs.image }}
60-
BRANCH: ${{ inputs.branch }}
59+
BRANCH: ${{ github.ref_name }}
6160
EXTRA_TAG: ${{ inputs.extra_tag }}
6261
LATEST: ${{ inputs.latest }}
6362
run: |
@@ -104,15 +103,18 @@ jobs:
104103
tags: ${{ steps.tags.outputs.tags }}
105104
provenance: mode=max
106105
sbom: true
107-
# Keyed per platform set so a run for one platform list doesn't evict another's cache.
108-
cache-from: type=gha,scope=release-${{ inputs.platforms }}
109-
cache-to: type=gha,mode=max,scope=release-${{ inputs.platforms }}
106+
# One shared scope: a `type=gha` value is itself a comma-separated key=value list,
107+
# so interpolating the (comma-separated) platform list into `scope` would end the
108+
# value early and buildx would reject the leftover as a key. Sharing the scope also
109+
# lets a single-platform run reuse the layers a multi-arch run already cached.
110+
cache-from: type=gha,scope=release
111+
cache-to: type=gha,mode=max,scope=release
110112
labels: |
111113
org.opencontainers.image.title=actor-runtime
112114
org.opencontainers.image.description=A minimal, self-contained local Apify platform in a single Docker image.
113115
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
114116
org.opencontainers.image.revision=${{ steps.tags.outputs.revision }}
115-
org.opencontainers.image.version=${{ inputs.branch }}
117+
org.opencontainers.image.version=${{ github.ref_name }}
116118
117119
- name: Summary
118120
env:

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ Images currently go to the temporary dev repository
121121
will move to an Apify-owned namespace later).
122122

123123
The **Release Docker image** workflow (`.github/workflows/release.yml`) is manual only: Actions ->
124-
Release Docker image -> Run workflow, then pick the branch to build (plus, optionally, an extra tag
125-
such as `v0.1.0`, whether to also move `:latest`, and which platforms to build). It pushes one
126-
multi-arch manifest per tag - `linux/amd64` and `linux/arm64` by default - so the same tag serves
127-
x86_64 and Apple Silicon.
128-
129-
Every run publishes `<branch>-<short-sha>` (immutable) and `<branch>` (moving). It needs two
130-
repository secrets: `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` (a Docker Hub access token with
131-
Read/Write from <https://hub.docker.com/settings/security>).
124+
Release Docker image -> Run workflow, pick the branch in **Use workflow from**, and run it. That is
125+
the only branch to choose - the workflow always builds the branch it was dispatched from. Everything
126+
else is optional: an extra tag such as `v0.1.0`, whether to also move `:latest`, and which platforms
127+
to build.
128+
129+
It pushes one multi-arch manifest per tag - `linux/amd64` and `linux/arm64` by default - so the same
130+
tag serves x86_64 and Apple Silicon. Every run publishes `<branch>-<short-sha>` (immutable) and
131+
`<branch>` (moving), with `/` in a branch name slugified to `-`. It needs two repository secrets:
132+
`DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` (a Docker Hub access token with Read/Write from
133+
<https://hub.docker.com/settings/security>).
132134

133135
## Development
134136

0 commit comments

Comments
 (0)