Purge Cloudflare cache on build

This commit is contained in:
2018-03-07 18:18:26 +00:00
parent 0a50282c27
commit 377f9b6609

View File

@@ -1,7 +1,27 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Build and copy theme files
npm run build npm run build
cp -vfr theme windycoys cp -vfr theme windycoys
cat windycoys/style.css # Purge Cloudflair cache
if [[ -z "${CLOUDFLARE_API_KEY}" ]] || [[ -z "${CLOUDFLARE_EMAIL}" ]] || [[ -z "${CLOUDFLARE_IDENTIFIER}" ]]; then
echo "Error: Cloudflare environment variables missing"
exit 1
fi
read -r -d '' DATA << EOM
{
"files": [
"https://beta.windycoys.com/wp-content/themes/windycoys/style.css",
"https://beta.windycoys.com/wp-content/themes/windycoys/bundle.js"
]
}
EOM
curl -X DELETE \
-H "Content-Type: application/json" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
--data "$DATA" \
"https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_IDENTIFIER/purge_cache"