From 0edd8652146098d32570e00c307b1d68f2079cee Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Mon, 15 Jan 2024 14:46:14 +0100 Subject: cdn: script --- cdn.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 cdn.sh diff --git a/cdn.sh b/cdn.sh new file mode 100755 index 0000000..a9b8dce --- /dev/null +++ b/cdn.sh @@ -0,0 +1,39 @@ +#/usr/bin/env bash + +# Sets up the ""CDN"" for the site (actually just a GitHub Pages branch). +# Steps: +# 1. Delete the old CDN branch +# 2. Create a new CDN branch +# 3. Remove all files except public/* +# 4. Copy public/* to the CDN branch +# 5. Commit and push the CDN branch +# +# Print progress along the way + +set -e + +echo "[1/5] Deleting old CDN branch" +git branch -D cdn || true + +echo "[2/5] Creating new CDN branch" +git checkout --orphan cdn +git reset --hard + +echo "[3/5] Removing all files except public/*" +dirs=$(find . -maxdepth 1 -type d -not -name public -not -name .git -not -name . -not -name ..) +for dir in $dirs; do + echo "Removing $dir" + rm -rf $dir +done + +echo "[4/5] Copying public/* to CDN branch" +cp -r public/* . + +echo "[5/5] Committing and pushing CDN branch" +git add -A +git commit -m "Update CDN" +git push -f origin cdn + +git checkout main + +echo "Done!" -- cgit v1.3.1