Touch archives on hit and prune the cache store after restore

Record last use by touching the archive so the retention policy can
expire by access time, and run prune.sh after every restore (even on
miss) to keep the shared store trimmed: keep the 3 newest archives per
key-prefix family, expire anything older than 7 days, hard-cap the store
at 2 GB (oldest first, trumping the keep set), never touch files younger
than 1h, and drop stale run workspaces under ~/.cache/act older than 2
days.
This commit is contained in:
2026-08-14 22:54:47 +08:00
parent 2d128b5303
commit 43f1755c0e
3 changed files with 121 additions and 2 deletions
+11 -2
View File
@@ -40,9 +40,18 @@ runs:
if [ -f "$ARCHIVE" ]; then
echo "Cache hit: ${CACHE_KEY}"
mkdir -p "$EXPANDED_PATH"
tar -xf "$ARCHIVE" -C "/" 2>/dev/null || true
echo "cache-hit=true" >> $GITHUB_OUTPUT
if tar -xf "$ARCHIVE" -C "/" 2>/dev/null; then
# record last use so the retention policy can expire by access time
touch "$ARCHIVE"
echo "cache-hit=true" >> $GITHUB_OUTPUT
else
echo "Cache restore failed"
echo "cache-hit=false" >> $GITHUB_OUTPUT
fi
else
echo "Cache miss: ${CACHE_KEY}"
echo "cache-hit=false" >> $GITHUB_OUTPUT
fi
# Trim the shared cache store and stale workspaces (best-effort)
bash "${{ github.action_path }}/prune.sh" || true