Create restore-only action
This commit is contained in:
+2
-24
@@ -1,5 +1,5 @@
|
|||||||
name: 'Cache'
|
name: 'Cache Restore'
|
||||||
description: 'Cache build files as tar.xz on the runner filesystem'
|
description: 'Restore cache from tar.xz archive on the runner filesystem'
|
||||||
inputs:
|
inputs:
|
||||||
path:
|
path:
|
||||||
description: 'Directory to cache'
|
description: 'Directory to cache'
|
||||||
@@ -44,25 +44,3 @@ runs:
|
|||||||
echo "Cache miss: ${CACHE_KEY}"
|
echo "Cache miss: ${CACHE_KEY}"
|
||||||
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Save cache
|
|
||||||
if: steps.restore.outputs.cache-hit != 'true'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
CACHE_DIR="$HOME/.cache/.cache-store"
|
|
||||||
mkdir -p "$CACHE_DIR"
|
|
||||||
|
|
||||||
KEY_HASH=$(sha256sum "${{ inputs.key-file }}" | awk '{print $1}')
|
|
||||||
CACHE_KEY="${{ inputs.key-prefix }}-${KEY_HASH}"
|
|
||||||
ARCHIVE="${CACHE_DIR}/${CACHE_KEY}.tar.xz"
|
|
||||||
|
|
||||||
EXPANDED_PATH=$(eval echo "${{ inputs.path }}")
|
|
||||||
|
|
||||||
if [ ! -d "$EXPANDED_PATH" ] || [ -z "$(ls -A "$EXPANDED_PATH" 2>/dev/null)" ]; then
|
|
||||||
echo "Cache directory empty, skipping save"
|
|
||||||
exit 0
|
|
||||||
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