Skip to content

Commit 60d913d

Browse files
JacobCoffeeclaude
andcommitted
fix(cdn): smart surrogate key detection for Fastly cache purge
Only purge section-specific keys when app templates/static change, fall back to full site purge for global template/static changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 907515a commit 60d913d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/purge-cache.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ jobs:
1919
purge:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v4
23-
if: inputs.target == ''
22+
- uses: actions/checkout@v6
23+
if: github.event_name == 'push'
2424
with:
25-
fetch-depth: 2
25+
fetch-depth: 0
2626

2727
- name: Resolve keys
2828
id: keys
2929
run: |
3030
if [ -n "${{ inputs.target }}" ]; then
3131
echo "keys=${{ inputs.target }}" >> "$GITHUB_OUTPUT"
32-
elif git diff --name-only HEAD~1 HEAD | grep -qE '^(static/|templates/)'; then
32+
elif git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -qE '^(static/|templates/)'; then
3333
echo "keys=pydotorg-app" >> "$GITHUB_OUTPUT"
3434
else
35-
echo "keys=$(git diff --name-only HEAD~1 HEAD | grep -oP '^apps/\K[^/]+(?=/(templates|static)/)' | sort -u | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
35+
echo "keys=$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -oP '^apps/\K[^/]+(?=/(templates|static)/)' | sort -u | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
3636
fi
3737
3838
- name: Purge ${{ steps.keys.outputs.keys || 'pydotorg-app' }}

0 commit comments

Comments
 (0)