diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5a206ced8da2594e029811b6ed0076fa2a87c321..537482f22f2f46fb217ab5a8180b8e8ab3ad0e15 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,4 +70,26 @@ pages: rules: - if: $CI_COMMIT_BRANCH == 'custom-domain' +# Purge all of this site's URLs from the Cloudflare cache +purge-cache: + stage: .post + tags: + - docker + rules: + - if: $CF_PURGE_CACHE_ZONE && $CF_PURGE_CACHE_TOKEN + script: + - >- + FILES="{ \"files\": [\"$CI_PAGES_URL/\""; + for d in $(find public/* -type d); do FILES="$FILES,\"$CI_PAGES_URL/${d#public/}/\""; done; + for f in $(find public -type f); do FILES="$FILES,\"$CI_PAGES_URL/${f#public/}\""; done; + FILES="$FILES] }" + - echo $FILES + - >- + wget -qO- "https://api.cloudflare.com/client/v4/zones/$CF_PURGE_CACHE_ZONE/purge_cache" + --header "Content-Type: application/json" + --header "Authorization: Bearer $CF_PURGE_CACHE_TOKEN" + --post-data "$FILES" + + + # vi: set ts=2 sw=2 et ft=yaml: