summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-08-12 15:19:45 +0200
committerDavid Lönnhager <david.l@mullvad.net>2025-08-12 15:19:45 +0200
commitdd67e9bca4a57cdcf4d027d3a47471443283c384 (patch)
tree127ccbe8be4a1fa2d83cf53ce753f7f82d1f4862
parent2ebbcdfc72d3435c9ef95f91ddfb1cd74f4f4ec0 (diff)
parent3f3815f4df165f6637d6deb6e2f9c49ab4c96f1e (diff)
downloadmullvadvpn-dd67e9bca4a57cdcf4d027d3a47471443283c384.tar.xz
mullvadvpn-dd67e9bca4a57cdcf4d027d3a47471443283c384.zip
Merge branch 'invalidate-cdn-cache-on-release'
-rw-r--r--ci/buildserver-config.sh4
-rwxr-xr-xci/buildserver-upload.sh17
2 files changed, 21 insertions, 0 deletions
diff --git a/ci/buildserver-config.sh b/ci/buildserver-config.sh
index 00f770dbeb..692d27cb1d 100644
--- a/ci/buildserver-config.sh
+++ b/ci/buildserver-config.sh
@@ -20,3 +20,7 @@ export CARGO_REGISTRY_VOLUME_NAME="cargo-registry"
# Where buildserver-build.sh should move artifacts (on Linux) and where
# buildserver-upload.sh should pick artifacts to upload
export UPLOAD_DIR="PLEASE CONFIGURE ME"
+
+# Used by buildserver-upload.sh to invalidate the CDN cache
+export BUNNYCDN_PULL_ZONE_ID="PLEASE CONFIGURE ME"
+export BUNNYCDN_API_KEY="PLEASE CONFIGURE ME"
diff --git a/ci/buildserver-upload.sh b/ci/buildserver-upload.sh
index d9bae81e5b..06ee45ba2b 100755
--- a/ci/buildserver-upload.sh
+++ b/ci/buildserver-upload.sh
@@ -12,6 +12,14 @@ source "$SCRIPT_DIR/buildserver-config.sh"
cd "$UPLOAD_DIR"
+function invalidate_bunny_cdn_cache {
+ curl --request POST \
+ --url "https://api.bunny.net/pullzone/${BUNNYCDN_PULL_ZONE_ID}/purgeCache" \
+ --header "AccessKey: ${BUNNYCDN_API_KEY}" \
+ --header 'content-type: application/json' \
+ --fail-with-body
+}
+
function rsync_upload {
local file=$1
local upload_dir=$2
@@ -23,6 +31,9 @@ function rsync_upload {
while true; do
sleep 10
+
+ should_invalidate_bunny_cdn_cache="false"
+
for checksums_path in **/*.sha256; do
sleep 1
@@ -43,6 +54,7 @@ while true; do
upload_path="$platform/builds"
else
upload_path="$platform/releases"
+ should_invalidate_bunny_cdn_cache="true"
fi
# Read all files listed in the checksum file at $checksums_path into an array.
@@ -74,4 +86,9 @@ while true; do
# shellcheck disable=SC2216
yes | rm "$checksums_path"
done
+
+ if [[ "$should_invalidate_bunny_cdn_cache" == "true" ]]; then
+ echo "Invalidating Bunny CDN cache"
+ invalidate_bunny_cdn_cache || continue
+ fi
done