3 Commits

+10 -17
View File
@@ -1,5 +1,5 @@
name: 'Cache Restore' name: 'Cache Save'
description: 'Restore cache from tar.xz archive on the runner filesystem' description: 'Save cache as tar.xz archive on the runner filesystem'
inputs: inputs:
path: path:
description: 'Directory to cache' description: 'Directory to cache'
@@ -11,15 +11,10 @@ inputs:
key-file: key-file:
description: 'File to hash for the cache key' description: 'File to hash for the cache key'
required: true required: true
outputs:
cache-hit:
description: 'true if exact key match found, false otherwise'
value: ${{ steps.restore.outputs.cache-hit }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Restore cache - name: Save cache
id: restore
shell: bash shell: bash
run: | run: |
CACHE_DIR="$HOME/.cache/.cache-store" CACHE_DIR="$HOME/.cache/.cache-store"
@@ -34,15 +29,13 @@ runs:
echo "Key file: ${{ inputs.key-file }}" echo "Key file: ${{ inputs.key-file }}"
echo "Path input: ${{ inputs.path }}" echo "Path input: ${{ inputs.path }}"
echo "Expanded path: ${EXPANDED_PATH}" echo "Expanded path: ${EXPANDED_PATH}"
echo "Cache key: ${CACHE_KEY}"
echo "Archive path: ${ARCHIVE}" echo "Archive path: ${ARCHIVE}"
if [ -f "$ARCHIVE" ]; then if [ ! -d "$EXPANDED_PATH" ] || [ -z "$(ls -A "$EXPANDED_PATH" 2>/dev/null)" ]; then
echo "Cache hit: ${CACHE_KEY}" echo "Cache directory empty, skipping save"
mkdir -p "$EXPANDED_PATH" exit 0
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 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"