Retry CDN purge requests and warn on failure
This commit is contained in:
1 parent
a87baf48d1
commit
750f3dce95
1 file changed
+56
-4
@@ -565,10 +565,36 @@ jobs:
|
||||
- name: Purge CDN cache
|
||||
run: |
|
||||
cd basic
|
||||
for file in $(ls); do
|
||||
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@basic/${file}"
|
||||
failed_files=()
|
||||
for file in *; do
|
||||
[[ -f "$file" ]] || continue
|
||||
purge_url="https://purge.jsdelivr.net/gh/${{ github.repository }}@basic/${file}"
|
||||
purge_succeeded=false
|
||||
|
||||
for attempt in 1 2 3; do
|
||||
echo "Purging ${file} from basic CDN cache (attempt ${attempt}/3)"
|
||||
if curl --fail --show-error --silent --location --max-time 30 "$purge_url"; then
|
||||
purge_succeeded=true
|
||||
echo
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ $attempt -lt 3 ]]; then
|
||||
echo "Retrying ${file} after transient purge failure"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $purge_succeeded == false ]]; then
|
||||
failed_files+=("$file")
|
||||
echo "::warning::Failed to purge jsDelivr cache for ${file} on the basic branch after 3 attempts."
|
||||
fi
|
||||
done
|
||||
|
||||
if (( ${#failed_files[@]} > 0 )); then
|
||||
printf 'Files with purge warnings on basic: %s\n' "${failed_files[*]}"
|
||||
fi
|
||||
|
||||
purge-universal-rulesets-cdn-cache:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-publish-universal-rulesets
|
||||
@@ -583,6 +609,32 @@ jobs:
|
||||
- name: Purge CDN cache
|
||||
run: |
|
||||
cd universal
|
||||
for file in $(ls); do
|
||||
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@universal/${file}"
|
||||
failed_files=()
|
||||
for file in *; do
|
||||
[[ -f "$file" ]] || continue
|
||||
purge_url="https://purge.jsdelivr.net/gh/${{ github.repository }}@universal/${file}"
|
||||
purge_succeeded=false
|
||||
|
||||
for attempt in 1 2 3; do
|
||||
echo "Purging ${file} from universal CDN cache (attempt ${attempt}/3)"
|
||||
if curl --fail --show-error --silent --location --max-time 30 "$purge_url"; then
|
||||
purge_succeeded=true
|
||||
echo
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ $attempt -lt 3 ]]; then
|
||||
echo "Retrying ${file} after transient purge failure"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $purge_succeeded == false ]]; then
|
||||
failed_files+=("$file")
|
||||
echo "::warning::Failed to purge jsDelivr cache for ${file} on the universal branch after 3 attempts."
|
||||
fi
|
||||
done
|
||||
|
||||
if (( ${#failed_files[@]} > 0 )); then
|
||||
printf 'Files with purge warnings on universal: %s\n' "${failed_files[*]}"
|
||||
fi
|
||||
Reference in new issue
Block a user