-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof of concept: Bust cloudflare cache (#333)
* Bust cloudflare cache * wip
- Loading branch information
1 parent
b0b5642
commit 4a50ac7
Showing
4 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
/public/sitemap*.xml | ||
/storage/*.key | ||
/vendor | ||
/modified | ||
.DS_Store | ||
.env | ||
.phpunit.result.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
base=${base:-/home/forge/laravel.com} | ||
docs=${base}/resources/docs | ||
|
||
# cd ${docs}/5.5 && git pull origin 5.5 | ||
# cd ${docs}/5.8 && git pull origin 5.8 | ||
# cd ${docs}/6.0 && git pull origin 6.0 | ||
# cd ${docs}/6.x && git pull origin 6.x | ||
# cd ${docs}/7.x && git pull origin 7.x | ||
cd ${docs}/8.x && git pull origin 8.x | ||
cd ${docs}/9.x && git pull origin 9.x | ||
cd ${docs}/10.x && git pull origin 10.x | ||
cd ${docs}/11.x && git pull origin 11.x | ||
cd ${docs}/master && git pull origin master | ||
versions=('8.x' '9.x' '10.x' '11.x' 'master') | ||
|
||
for version in "${versions[@]}" | ||
do | ||
cd "${base}/resources/docs/${version}" | ||
previousHash=$(git rev-parse "${version}") | ||
git fetch origin "${version}" | ||
|
||
if [[ "${previousHash}" == $(git rev-parse "origin/${version}") ]]; then | ||
continue | ||
fi | ||
|
||
git pull origin "${version}" | ||
git diff --name-only $previousHash HEAD | while read markdownFile; do | ||
echo "https://laravel.com/docs/${version}/$(basename $markdownFile '.md')" >> "${base}/modified" | ||
done | ||
done | ||
|
||
if [ ! -f "${base}/modified" ]; then | ||
exit 0 | ||
fi | ||
|
||
files=$(jq --raw-input --slurp 'split("\n") | map(select(. != "")) | unique' "${base}/modified") | ||
curl -X POST --fail \ | ||
"https://api.cloudflare.com/client/v4/zones/${1}/purge_cache" \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${2}" \ | ||
-d "{ \"files\": ${files} }" | ||
rm "${base}/modified" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters