Skip to content

Commit c75cdc9

Browse files
committed
Purge Cloudflare Cache if config file exists
1 parent 0c18e7f commit c75cdc9

File tree

1 file changed

+12
-0
lines changed
  • application/console/views/cron/scripts/upload/default

1 file changed

+12
-0
lines changed

application/console/views/cron/scripts/upload/default/publish.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ publish_rclone() {
313313
fi
314314
PUBLISH_URL="${PUBLISH_BASE_URL}/${PUBLISH_REMOTE_PATH}/${PUBLISH_FILE}"
315315
echo "${PUBLISH_URL}" > "${OUTPUT_DIR}/publish_url.txt"
316+
317+
CLOUDFLARE_PURGE_CONFIG="${SECRETS_DIR}/cloudflare_purge.json"
318+
if [ -f "${CLOUDFLARE_PURGE_CONFIG}" ]; then
319+
CLOUDFLARE_ZONE=$(jq -r '.zone' "${CLOUDFLARE_PURGE_CONFIG}")
320+
CLOUDFLARE_API_KEY=$(jq -r '.key' "${CLOUDFLARE_PURGE_CONFIG}")
321+
322+
curl --request POST \
323+
--url "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
324+
--header 'Content-Type: application/json' \
325+
--header "Authorization: Bearer ${CLOUDFLARE_API_KEY}" \
326+
--data "{ \"files\" : [ \"${PUBLISH_URL}\" ]}"
327+
fi
316328
}
317329

318330
publish_gradle() {

0 commit comments

Comments
 (0)