Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions actions/github/artifact/cache/restore/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ inputs:
wf-path:
type: string
required: true
max-retries:
type: number
required: false
default: 3
retry-delay:
type: number
required: false
default: 10


runs:
Expand All @@ -40,17 +48,33 @@ runs:
|| steps.cache-id.outputs.id
shell: bash
run: |
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${REPOSITORY}/actions/artifacts/${ARTIFACT_ID}/zip" \
| tar --warning=no-timestamp \
--keep-directory-symlink \
-xI unzstd \
-f - \
-C ${OUTPUT_PATH}
for attempt in $(seq 1 "$MAX_RETRIES"); do
echo "Attempt $attempt of $MAX_RETRIES"
if gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${REPOSITORY}/actions/artifacts/${ARTIFACT_ID}/zip" \
| tar --warning=no-timestamp \
--keep-directory-symlink \
-xI unzstd \
-f - \
-C ${OUTPUT_PATH}; then
echo "Cache restored successfully"
exit 0
fi
if [[ "$attempt" -lt "$MAX_RETRIES" ]]; then
echo "::warning::Attempt $attempt failed, retrying in ${RETRY_DELAY}s..."
find "${OUTPUT_PATH:?}" -mindepth 1 -delete
sleep "$RETRY_DELAY"
fi
RETRY_DELAY=$((RETRY_DELAY * 2))
done
echo "::error::Failed to restore artifact cache after $MAX_RETRIES attempts"
exit 1
env:
GH_TOKEN: ${{ inputs.token }}
ARTIFACT_ID: ${{ inputs.id || steps.cache-id.outputs.id }}
OUTPUT_PATH: ${{ inputs.path }}
REPOSITORY: ${{ inputs.repository }}
MAX_RETRIES: ${{ inputs.max-retries }}
RETRY_DELAY: ${{ inputs.retry-delay }}