Skip to content

build-push-ecr: layer cache in the Actions cache and ECR on hosted runners - #83

Closed
hamishfagg wants to merge 1 commit into
mainfrom
feat/build-cache
Closed

hamishfagg wants to merge 1 commit into
mainfrom
feat/build-cache

Conversation

@hamishfagg

@hamishfagg hamishfagg commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

On a GitHub-hosted runner docker buildx build runs from a run: step, which has no ACTIONS_RUNTIME_TOKEN, so buildx silently skipped the type=gha cache flags and every build started cold. This PR:

  • adds a github-script step (hosted path only) that copies the runner's ACTIONS_* variables into the job environment, which is what the gha backend reads;
  • passes --cache-from/--cache-to for two caches per image: the Actions cache with scope=<module-name>, and <image>:buildcache in ECR, both mode=max;
  • leaves the remote-builder path without cache flags, since the in-cluster agent keeps its own cache;
  • drops FranzDiebold/github-env-vars-action from this action (its only used value was CI_SHA, which github.sha holds) and moves the inputs into the step's env.

Call sites are unchanged. extra-build-args is still split on whitespace and expanded on the build line.

Tested on mindsdb/scratchpad-controller#144, whose build job checks out this branch:

  • run 1: both caches imported (ECR ref not found yet, build continued), both exported.
  • run 2: controller build 11s against 71s, every layer CACHED. The browser build gets no hits because its --no-cache-filter base invalidates every later stage.

🤖 Generated with Claude Code

…unners

The gha cache flags were dropped from a `run:` step because buildx had no
ACTIONS_RUNTIME_TOKEN there. A github-script step now copies the runner's
ACTIONS_* variables into the job environment, and a hosted build imports
from and exports to both the Actions cache (scope <module-name>) and
<image>:buildcache in ECR, mode=max. The remote-builder path keeps its
local cache and passes no cache flags.

Inputs reach the script through env rather than inline expressions, and
the github-env-vars action is gone: the only value it supplied was the
sha, which github.sha already holds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hamishfagg
hamishfagg requested a review from a team as a code owner November 18, 2026 22:55
@hamishfagg

Copy link
Copy Markdown
Contributor Author

Superseded by a new build-image action built on docker/build-push-action; this one stays as it is until its last caller moves.

@hamishfagg hamishfagg closed this Nov 18, 2026
@hamishfagg
hamishfagg deleted the feat/build-cache branch November 18, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant