Skip to content

Commit 1cb7935

Browse files
committed
Merge branch 'invalidate-cdn-cache-on-linux-repo-upload'
2 parents 1c7d7a2 + 2fd45ad commit 1cb7935

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ci/linux-repository-builder/build-linux-repositories-config.sh

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ export DEV_LINUX_REPOSITORY_PUBLIC_URL="https://repository.devmole.eu"
3030
export PRODUCTION_REPOSITORY_SERVER="cdn.mullvad.net"
3131
export STAGING_REPOSITORY_SERVER="cdn.stagemole.eu"
3232
export DEV_REPOSITORY_SERVER="cdn.devmole.eu"
33+
34+
#export PRODUCTION_BUNNYCDN_PULL_ZONE_ID="PLEASE CONFIGURE ME"
35+
#export STAGING_BUNNYCDN_PULL_ZONE_ID="PLEASE CONFIGURE ME"
36+
#export BUNNYCDN_API_KEY="PLEASE CONFIGURE ME"

ci/linux-repository-builder/build-linux-repositories.sh

+21
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ case "$environment" in
4949
"production")
5050
repository_server_upload_domain="$PRODUCTION_REPOSITORY_SERVER"
5151
repository_server_public_url="$PRODUCTION_LINUX_REPOSITORY_PUBLIC_URL"
52+
bunnycdn_pull_zone_id="$PRODUCTION_BUNNYCDN_PULL_ZONE_ID"
5253
;;
5354
"staging")
5455
repository_server_upload_domain="$STAGING_REPOSITORY_SERVER"
5556
repository_server_public_url="$STAGING_LINUX_REPOSITORY_PUBLIC_URL"
57+
bunnycdn_pull_zone_id="$STAGING_BUNNYCDN_PULL_ZONE_ID"
5658
;;
5759
"dev")
5860
repository_server_upload_domain="$DEV_REPOSITORY_SERVER"
@@ -144,6 +146,16 @@ function rsync_repo {
144146
build@"$repository_server_upload_domain":"$remote_repo_dir"
145147
}
146148

149+
function invalidate_bunny_cdn_cache {
150+
local pull_zone_id=$1
151+
curl --request POST \
152+
--url "https://api.bunny.net/pullzone/${pull_zone_id}/purgeCache" \
153+
--header "AccessKey: ${BUNNYCDN_API_KEY}" \
154+
--header 'content-type: application/json' \
155+
--fail-with-body
156+
}
157+
158+
repositories_were_updated="false"
147159
for repository in "${REPOSITORIES[@]}"; do
148160
deb_remote_repo_dir="deb/$repository"
149161
rpm_remote_repo_dir="rpm/$repository"
@@ -183,4 +195,13 @@ for repository in "${REPOSITORIES[@]}"; do
183195
echo "[#] Syncing rpm repository to $rpm_remote_repo_dir"
184196
rsync_repo "$rpm_repo_dir" "$rpm_remote_repo_dir"
185197

198+
echo "[#] ==== Done updating $repository in $environment ===="
199+
repositories_were_updated="true"
186200
done
201+
202+
if [[ "$repositories_were_updated" == "true" ]]; then
203+
if [[ "$environment" == "production" || "$environment" == "staging" ]]; then
204+
echo "[#] Invalidating Bunny CDN cache for pull zone $bunnycdn_pull_zone_id"
205+
invalidate_bunny_cdn_cache "$bunnycdn_pull_zone_id"
206+
fi
207+
fi

0 commit comments

Comments
 (0)