From f10b60398910d10176ce35a6bb90acde2a6f2f09 Mon Sep 17 00:00:00 2001
From: Paul Schnetzinger
Date: Mon, 20 Jul 2026 14:11:44 +0200
Subject: [PATCH] feat: add cache-from/cache-to passthrough to
build-push-action
Lets consumers wire external build caches (e.g. GitHub Actions cache,
registry cache) through to docker/build-push-action, which already
supports cache-from/cache-to natively. Without this the composite
action forces every build to start cold, since GitHub-hosted runners
are fresh VMs per job and local buildx cache never persists across
runs regardless of builder lifecycle.
Backward compatible: both inputs default to empty string, matching
existing optional-input behavior in this action.
---
README.md | 2 ++
action.yml | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/README.md b/README.md
index 46f9cfa..a1180de 100644
--- a/README.md
+++ b/README.md
@@ -120,6 +120,8 @@ context|The build context directory (the directory containing your Dockerfile an
dockerfile|Filename of the Dockerfile within the context that you set.| |`./Dockerfile`
platforms|Comma separated list of platforms.| |`linux/amd64`
target|The target build stage to build.| |
+cache-from|List of external cache sources for the build (e.g., `type=gha`). Passed directly to `docker/build-push-action`.| |
+cache-to|List of cache export destinations for the build (e.g., `type=gha,mode=max`). Passed directly to `docker/build-push-action`.| |
#### If you have more than one registry
**🔀 Input Name**|**📚 Description**|**🛑 Required**|**👉 Default**
diff --git a/action.yml b/action.yml
index 195095f..42e5ec3 100644
--- a/action.yml
+++ b/action.yml
@@ -49,6 +49,14 @@ inputs:
description: 'Comma separated list of platforms.'
default: 'linux/amd64'
required: false
+ cache-from:
+ description: 'List of external cache sources for the build (e.g., "type=gha"). Passed directly to docker/build-push-action.'
+ default: ''
+ required: false
+ cache-to:
+ description: 'List of cache export destinations for the build (e.g., "type=gha,mode=max"). Passed directly to docker/build-push-action.'
+ default: ''
+ required: false
runs:
using: 'composite'
steps:
@@ -92,6 +100,8 @@ runs:
push: true
tags: ${{ inputs.tags }}
target: ${{ inputs.target }}
+ cache-from: ${{ inputs.cache-from }}
+ cache-to: ${{ inputs.cache-to }}
branding:
icon: 'server'
color: 'blue'