Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

lith: auto-purge Cloudflare cache on system/public/* changes

Webhook now POSTs purge_everything via a zone-scoped CF API token
whenever a deploy touches any static file under system/public/*.
Env: CLOUDFLARE_PURGE_TOKEN, CLOUDFLARE_ZONE_ID (in /opt/ac/system/.env).
Non-fatal on API failure — deploy continues.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+23 -1
+23 -1
lith/webhook.sh
··· 63 63 NEED_CADDY_RELOAD=false 64 64 NEED_NPM_INSTALL=false 65 65 NEED_DP1_FEED_RESTART=false 66 + NEED_CF_PURGE=false 66 67 67 68 while IFS= read -r file; do 68 69 case "$file" in ··· 90 91 NEED_DP1_FEED_RESTART=true 91 92 ;; 92 93 system/public/*) 93 - # Static files — Caddy serves directly from disk, no action needed 94 + # Static files — Caddy serves directly from disk, but Cloudflare 95 + # caches them at the edge for up to an hour, so we need to purge. 96 + NEED_CF_PURGE=true 94 97 ;; 95 98 *) 96 99 # Other files (docs, tests, etc.) — no action needed ··· 124 127 systemctl restart lith 125 128 else 126 129 log "static-only deploy — no restart needed" 130 + fi 131 + 132 + if $NEED_CF_PURGE; then 133 + if [ -n "${CLOUDFLARE_PURGE_TOKEN:-}" ] && [ -n "${CLOUDFLARE_ZONE_ID:-}" ]; then 134 + log "purging Cloudflare cache for zone $CLOUDFLARE_ZONE_ID..." 135 + CF_RESPONSE=$(curl -sS -X POST \ 136 + "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ 137 + -H "Authorization: Bearer ${CLOUDFLARE_PURGE_TOKEN}" \ 138 + -H "Content-Type: application/json" \ 139 + --data '{"purge_everything":true}' \ 140 + --max-time 20 || echo '{"success":false,"errors":[{"message":"curl failed"}]}') 141 + if echo "$CF_RESPONSE" | grep -q '"success":true'; then 142 + log "Cloudflare cache purged" 143 + else 144 + log "WARN: Cloudflare purge failed: $CF_RESPONSE" 145 + fi 146 + else 147 + log "skipping CF purge (CLOUDFLARE_PURGE_TOKEN / CLOUDFLARE_ZONE_ID not set)" 148 + fi 127 149 fi 128 150 129 151 log "done"