build-cran-binaries/scripts/purge_cdn_cache.sh
pat-s 914b2e8af5
fix(ci): actually purge BunnyCDN cache in purge_cdn_cache.sh
The script defined a purge_cdn_cache() function but never invoked it,
so every CI run only declared the helper and exited cleanly without
issuing a single curl. The CDN had been relying entirely on the
Cache-Control: no-cache headers R writes onto PACKAGES* objects.

Rewrite to call the purge inline; while here:
- drop `set -x` (leaked the AccessKey header into logs)
- drop the python3 urlencoder; `curl --data-urlencode` does the
  same with no Python dep, so the workflow purge step no longer
  needs `apk add bash curl` over `curl --data-urlencode`-capable
  curl alone
- add `src/contrib/Meta/archive.rds` to the resource list - it
  changes during process-updates and was being served stale
2026-05-28 15:48:03 +02:00

44 lines
963 B
Shell

#!/usr/bin/env bash
#
# Purge BunnyCDN edge cache for the index files of one ARCH+OS_ID
# combination across one or more domains.
#
# Usage:
# purge_cdn_cache.sh <BUNNYNET_API_KEY> <ARCH> <OS_ID> <domain> [<domain>...]
#
set -euo pipefail
if (( $# < 4 )); then
echo "usage: $0 <api_key> <arch> <os_id> <domain> [<domain>...]" >&2
exit 2
fi
api_key="$1"
arch="$2"
os_id="$3"
shift 3
resources=(
"src/contrib/PACKAGES"
"src/contrib/PACKAGES.gz"
"src/contrib/PACKAGES.rds"
"src/contrib/PACKAGES.db"
"src/contrib/Meta/archive.rds"
)
purge_one() {
local target="$1"
# --data-urlencode encodes value of `url=` for us; -G forces GET.
curl -sS -G -X POST \
-H "AccessKey: ${api_key}" \
--data-urlencode "url=${target}" \
--data "async=false" \
"https://api.bunny.net/purge"
echo
}
for domain in "$@"; do
for resource in "${resources[@]}"; do
purge_one "https://${domain}/${arch}/${os_id}/latest/${resource}"
done
done