From 7f45aea1af9345c4d3880700dd42b827b731e136 Mon Sep 17 00:00:00 2001 From: Chris Coley <chris@codingallnight.com> Date: Sun, 30 Apr 2023 09:13:25 -0700 Subject: [PATCH] Re-enable Cloudflare purge, but only on default branch since pages only runs on default branch --- .gitlab-ci.yml | 6 +++++- purge-cache.gitlab-ci.yml | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9210749..4dbc82a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,11 +68,13 @@ review: pages: extends: .deploy rules: - - if: $CI_COMMIT_BRANCH == 'custom-domain' + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Purge all of this site's URLs from the Cloudflare cache create-purge-json: stage: deploy + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH needs: ['pages'] tags: - docker @@ -89,6 +91,8 @@ create-purge-json: trigger-cache-purge: stage: .post + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH trigger: include: purge-cache.gitlab-ci.yml variables: diff --git a/purge-cache.gitlab-ci.yml b/purge-cache.gitlab-ci.yml index cfe4a24..0b4c616 100644 --- a/purge-cache.gitlab-ci.yml +++ b/purge-cache.gitlab-ci.yml @@ -15,11 +15,11 @@ purge-cache: job: create-purge-json script: - cat purge.json -# - >- -# 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-file purge.json + - >- + 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-file purge.json # vi: set ts=2 sw=2 et ft=yaml: -- GitLab