Include runner image metadata in cache key

This commit is contained in:
copilot-swe-agent[bot] 2026-06-13 23:49:25 +00:00 committed by GitHub
parent 3902329b61
commit cccebf8faf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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}"