Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 985f68d26e | |||
| d869804b36 | |||
| 403aede6f3 |
+10
-17
@@ -1,5 +1,5 @@
|
||||
name: 'Cache Restore'
|
||||
description: 'Restore cache from tar.xz archive on the runner filesystem'
|
||||
name: 'Cache Save'
|
||||
description: 'Save cache as tar.xz archive on the runner filesystem'
|
||||
inputs:
|
||||
path:
|
||||
description: 'Directory to cache'
|
||||
@@ -11,15 +11,10 @@ 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: Restore cache
|
||||
id: restore
|
||||
- name: Save cache
|
||||
shell: bash
|
||||
run: |
|
||||
CACHE_DIR="$HOME/.cache/.cache-store"
|
||||
@@ -34,15 +29,13 @@ 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 [ -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
|
||||
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