Archive the cached dir relative, not by its absolute path
Each run gets a fresh per-run workspace (~/.cache/act/<hash>/hostexecutor), so embedding the absolute path meant the next run restored into a stale workspace and the cache never actually sped up a build. Save with -C <parent> <basename> so entries are <basename>/... and restores can extract into the run's own path input location.
This commit is contained in:
+6
-2
@@ -37,9 +37,13 @@ runs:
|
||||
fi
|
||||
|
||||
echo "Saving cache: ${CACHE_KEY}"
|
||||
REL_PATH="$(echo "$EXPANDED_PATH" | sed 's|^/||')"
|
||||
# Archive only the directory itself (entries: <basename>/...), not its
|
||||
# absolute path, so a later run can restore it into its own (per-run)
|
||||
# workspace location. Restores use the same `path` input to find it.
|
||||
PARENT="$(dirname "$EXPANDED_PATH")"
|
||||
BASE="$(basename "$EXPANDED_PATH")"
|
||||
TMP_ARCHIVE="${ARCHIVE}.tmp"
|
||||
if tar -cJf "$TMP_ARCHIVE" -C "/" "$REL_PATH" 2>/dev/null && mv -f "$TMP_ARCHIVE" "$ARCHIVE"; then
|
||||
if tar -cJf "$TMP_ARCHIVE" -C "$PARENT" "$BASE" 2>/dev/null && mv -f "$TMP_ARCHIVE" "$ARCHIVE"; then
|
||||
echo "Cache saved"
|
||||
else
|
||||
rm -f "$TMP_ARCHIVE"
|
||||
|
||||
Reference in New Issue
Block a user