aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanisław Zagórowski <hasohasacz@gmail.com>2024-01-15 14:46:14 +0100
committerStanisław Zagórowski <hasohasacz@gmail.com>2024-01-15 14:46:14 +0100
commit0edd8652146098d32570e00c307b1d68f2079cee (patch)
treee998de375930561bd2a04a1d786c399b26f9e27f
parent63ea67e4c3c8caa2cf0dc6d7c940981bd40b3974 (diff)
cdn: script
-rwxr-xr-xcdn.sh39
1 files changed, 39 insertions, 0 deletions
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!"