Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d128b5303 | |||
| 2d57ace5e4 | |||
| e744d2a004 |
+17
-10
@@ -1,5 +1,5 @@
|
||||
name: 'Cache Save'
|
||||
description: 'Save cache as tar.xz archive on the runner filesystem'
|
||||
name: 'Cache Restore'
|
||||
description: 'Restore cache from tar.xz archive on the runner filesystem'
|
||||
inputs:
|
||||
path:
|
||||
description: 'Directory to cache'
|
||||
@@ -11,10 +11,15 @@ inputs:
|
||||
key-file:
|
||||
description: 'File to hash for the cache key'
|
||||
required: true
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'true if exact key match found, false otherwise'
|
||||
value: ${{ steps.restore.outputs.cache-hit }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Save cache
|
||||
- name: Restore cache
|
||||
id: restore
|
||||
shell: bash
|
||||
run: |
|
||||
CACHE_DIR="$HOME/.cache/.cache-store"
|
||||
@@ -29,13 +34,15 @@ runs:
|
||||
echo "Key file: ${{ inputs.key-file }}"
|
||||
echo "Path input: ${{ inputs.path }}"
|
||||
echo "Expanded path: ${EXPANDED_PATH}"
|
||||
echo "Cache key: ${CACHE_KEY}"
|
||||
echo "Archive path: ${ARCHIVE}"
|
||||
|
||||
if [ ! -d "$EXPANDED_PATH" ] || [ -z "$(ls -A "$EXPANDED_PATH" 2>/dev/null)" ]; then
|
||||
echo "Cache directory empty, skipping save"
|
||||
exit 0
|
||||
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
|
||||
else
|
||||
echo "Cache miss: ${CACHE_KEY}"
|
||||
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
echo "Saving cache: ${CACHE_KEY}"
|
||||
REL_PATH="$(echo "$EXPANDED_PATH" | sed 's|^/||')"
|
||||
tar -cJf "$ARCHIVE" -C "/" "$REL_PATH" 2>/dev/null && echo "Cache saved" || echo "Cache save failed"
|
||||
|
||||
Reference in New Issue
Block a user