Refactor jsDelivr cache purge in workflow
Replaced the standalone 'purge-jsdelivr-cache' job with an inline step in the main workflow. The new implementation purges jsDelivr CDN cache for PNG files in the 'favicons' directory, improving progress tracking and simplifying the workflow structure.
This commit is contained in:
1 parent
76906d5e5f
commit
ebc102fd60
1 file changed
+22
-42
+22
-42
@@ -209,6 +209,28 @@ jobs:
|
||||
git push origin assets --force
|
||||
fi
|
||||
|
||||
- name: Purge jsDelivr CDN cache
|
||||
run: |
|
||||
echo "Purging jsDelivr CDN cache for assets branch..."
|
||||
# Change to directory with PNG files
|
||||
cd favicons
|
||||
|
||||
# Count files for progress tracking
|
||||
total_files=$(find . -name "*.png" | wc -l)
|
||||
echo "Purging cache for $total_files files"
|
||||
|
||||
count=0
|
||||
for file in $(find . -name "*.png" -type f -printf "%f\n"); do
|
||||
count=$((count + 1))
|
||||
if [ $((count % 100)) -eq 0 ]; then
|
||||
echo "Progress: Purged $count/$total_files files"
|
||||
fi
|
||||
|
||||
curl -s -o /dev/null -w "%{http_code}" "https://purge.jsdelivr.net/gh/${{ github.repository }}@assets/${file}"
|
||||
done
|
||||
|
||||
echo "jsDelivr CDN cache purge completed for $count files"
|
||||
|
||||
- name: Install tzst
|
||||
run: |
|
||||
echo "Installing tzst..."
|
||||
@@ -264,45 +286,3 @@ jobs:
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
purge-jsdelivr-cache:
|
||||
runs-on: ubuntu-latest
|
||||
needs: process-favicons-and-release
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Purge jsDelivr CDN cache
|
||||
run: |
|
||||
echo "Purging jsDelivr CDN cache for repository..."
|
||||
|
||||
# Get repository owner and name
|
||||
REPO_OWNER="${{ github.repository_owner }}"
|
||||
REPO_NAME="${{ github.event.repository.name }}"
|
||||
|
||||
# Purge the entire repository cache
|
||||
PURGE_URL="https://purge.jsdelivr.net/gh/${REPO_OWNER}/${REPO_NAME}@latest"
|
||||
|
||||
echo "Purging cache for: $PURGE_URL"
|
||||
|
||||
# Make the purge request
|
||||
if curl -X POST "$PURGE_URL" -H "Cache-Control: no-cache" -w "HTTP Status: %{http_code}\n" --fail; then
|
||||
echo "jsDelivr cache purged successfully"
|
||||
else
|
||||
echo "Warning: Failed to purge jsDelivr cache, but continuing workflow"
|
||||
echo "This is not critical and the cache will eventually update automatically"
|
||||
fi
|
||||
|
||||
# Also purge specific common endpoints that might be cached
|
||||
echo "Purging common endpoint caches..."
|
||||
ENDPOINTS=(
|
||||
"https://purge.jsdelivr.net/gh/${REPO_OWNER}/${REPO_NAME}@latest/archive.tzst"
|
||||
"https://purge.jsdelivr.net/gh/${REPO_OWNER}/${REPO_NAME}@latest/"
|
||||
)
|
||||
|
||||
for endpoint in "${ENDPOINTS[@]}"; do
|
||||
echo "Purging: $endpoint"
|
||||
curl -X POST "$endpoint" -H "Cache-Control: no-cache" -w "HTTP Status: %{http_code}\n" --fail --silent || echo "Failed to purge $endpoint"
|
||||
done
|
||||
|
||||
echo "jsDelivr CDN cache purge completed"
|
||||
Reference in new issue
Block a user