From cccebf8faf65872e3ec157ced3e4e9e37209cdd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 23:49:25 +0000 Subject: [PATCH] Include runner image metadata in cache key --- README.md | 2 +- pre_cache_action.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0d1c3b..cd879d1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ There are three kinds of version labels you can use. ### Cache scopes -The cache is scoped to the packages given and the branch. The default branch cache is available to other branches. +The cache is scoped to the packages given and the branch. The default branch cache is available to other branches. The cache key also includes runner image metadata (`ImageOS`, `ImageVersion`) when available so caches are invalidated as runner images change. ### Example workflow diff --git a/pre_cache_action.sh b/pre_cache_action.sh index 5cb64cb..4283bae 100755 --- a/pre_cache_action.sh +++ b/pre_cache_action.sh @@ -99,6 +99,17 @@ log "- CPU architecture is '${cpu_arch}'." value="${packages} @ ${version} ${force_update_inc}" +# Include runner image metadata in cache key when available to avoid stale +# cache hits when GitHub rotates images. +if [ -n "${ImageOS}" ]; then + value="${value} image_os:${ImageOS}" + log "- Runner image OS '${ImageOS}' added to value." +fi +if [ -n "${ImageVersion}" ]; then + value="${value} image_version:${ImageVersion}" + log "- Runner image version '${ImageVersion}' added to value." +fi + # Include repositories in cache key to ensure different repos get different caches if [ -n "${add_repository}" ]; then value="${value} ${add_repository}"