Create restore-only action
This commit is contained in:
+2
-24
@@ -1,5 +1,5 @@
|
||||
name: 'Cache'
|
||||
description: 'Cache build files as tar.xz on the runner filesystem'
|
||||
name: 'Cache Restore'
|
||||
description: 'Restore cache from tar.xz archive on the runner filesystem'
|
||||
inputs:
|
||||
path:
|
||||
description: 'Directory to cache'
|
||||
@@ -44,25 +44,3 @@ runs:
|
||||
echo "Cache miss: ${CACHE_KEY}"
|
||||
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
||||
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