From ededcc05c4a5b2650d5a7eb6f8d00496b61221e3 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Mon, 1 Apr 2019 15:30:36 -0400 Subject: [PATCH] purge cloudflare cache from CI pipeline --- .gitlab-ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9f14be7..1741ca3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.6-alpine +image: python:3.7-alpine variables: HUGO_VERSION: '0.53' # https://github.com/gohugoio/hugo/releases @@ -7,7 +7,7 @@ variables: before_script: # update alpine - - apk update && apk add openssl coreutils + - apk update && apk add openssl curl coreutils # download and install Hugo - wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz @@ -17,7 +17,7 @@ before_script: # install awscli - pip install --quiet --no-cache-dir awscli==${AWSCLI_VERSION} -deploy: +deploy: script: # build site - rm -rf public @@ -44,5 +44,12 @@ deploy: - aws s3 cp s3://$S3_BUCKET_NAME s3://$S3_BUCKET_NAME --exclude "*" --include "*.css" --include "*.js" --include "*.jpg" --include "*.png" --include "*.gif" --cache-control "max-age=604800, public" --metadata-directive="REPLACE" --recursive - aws s3 cp s3://$S3_BUCKET_NAME/jarvis.asc s3://$S3_BUCKET_NAME/jarvis.asc --content-type="text/plain; charset=utf-8" --cache-control "max-age=0, no-store, no-cache, must-revalidate" --content-disposition "inline; filename=\"jarvis.asc\"" --metadata-directive="REPLACE" + # purge CloudFlare cache + curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \ + -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \ + -H "X-Auth-Key: $CLOUDFLARE_KEY" \ + -H "Content-Type: application/json" \ + --data '{"purge_everything":true}' + only: - master