From fe0cd2d2925824e728ee3af90e1bf95bb30c2a09 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Fri, 17 Jul 2026 15:46:35 -0500 Subject: [PATCH 1/2] If web-php changes then bust Bunny CDN Cache --- inventory/php/group_vars/all.yml.skeleton | 3 +++ roles/properties/www/templates/update-www | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/inventory/php/group_vars/all.yml.skeleton b/inventory/php/group_vars/all.yml.skeleton index bc9c171..bdbf9a8 100644 --- a/inventory/php/group_vars/all.yml.skeleton +++ b/inventory/php/group_vars/all.yml.skeleton @@ -35,6 +35,9 @@ github_secret: bugs_magic_cookie: flickr_api_token: +# Bunny CDN account API key, used by update-www to purge the CDN cache +bunny_api_key: + # OhDearHealthChecks ohdear_secret: diff --git a/roles/properties/www/templates/update-www b/roles/properties/www/templates/update-www index 3c254f3..4ef089b 100644 --- a/roles/properties/www/templates/update-www +++ b/roles/properties/www/templates/update-www @@ -1,7 +1,19 @@ #!/bin/sh -rsync -rlptDC --timeout=600 --delete --delete-after \ +# export tokens +export BUNNY_API_KEY="{{ bunny_api_key }}" + +CHANGES=$(rsync -rlptDC --timeout=600 --delete --delete-after --itemize-changes \ --include='distributions/*.exe' --include='manual/en/' \ --include='manual/en/**' --include='manual/*.php' \ --include='manual/**' {{ rsync_address }}::phpweb \ - {{ www_docroot }} + {{ www_docroot }}) + +# Bust the Bunny CDN cache for the pre-release builds page, but only when +# rsync actually pulled new content (avoids purging on every 5-minute run) +if [ -n "$CHANGES" ]; then + curl --fail --silent --show-error --request POST \ + --url 'https://api.bunny.net/purge?url=https://www.php.net/pre-release-builds.php*' \ + --header "AccessKey: ${BUNNY_API_KEY}" +fi + From ccdac9e9ad7dbc9f6f19f0880107862f871a6ce6 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Wed, 29 Jul 2026 10:24:08 -0500 Subject: [PATCH 2/2] Loop over a url list for purging bunny cdn --- roles/properties/www/tasks/deploy.yml | 3 +++ roles/properties/www/templates/update-www | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/roles/properties/www/tasks/deploy.yml b/roles/properties/www/tasks/deploy.yml index 1ec3140..04804ce 100644 --- a/roles/properties/www/tasks/deploy.yml +++ b/roles/properties/www/tasks/deploy.yml @@ -9,6 +9,9 @@ src: templates/update-www dest: /local/systems/update-www mode: "700" + vars: + bunny_purge_urls: + - "https://www.php.net/pre-release-builds.php*" - name: Create a cron job to run every 5 minutes cron: diff --git a/roles/properties/www/templates/update-www b/roles/properties/www/templates/update-www index 4ef089b..2a2ce58 100644 --- a/roles/properties/www/templates/update-www +++ b/roles/properties/www/templates/update-www @@ -9,11 +9,14 @@ CHANGES=$(rsync -rlptDC --timeout=600 --delete --delete-after --itemize-changes --include='manual/**' {{ rsync_address }}::phpweb \ {{ www_docroot }}) -# Bust the Bunny CDN cache for the pre-release builds page, but only when -# rsync actually pulled new content (avoids purging on every 5-minute run) +# Bust the Bunny CDN cache, but only when rsync actually pulled new +# content (avoids purging on every 5-minute run). The Bunny purge API +# takes a single URL per request, so each one is a separate call. if [ -n "$CHANGES" ]; then - curl --fail --silent --show-error --request POST \ - --url 'https://api.bunny.net/purge?url=https://www.php.net/pre-release-builds.php*' \ - --header "AccessKey: ${BUNNY_API_KEY}" + for url in {% for url in bunny_purge_urls %}'{{ url }}' {% endfor %}; do + curl --fail --silent --show-error --request POST \ + --url "https://api.bunny.net/purge?url=${url}" \ + --header "AccessKey: ${BUNNY_API_KEY}" + done fi