aboutsummaryrefslogtreecommitdiffstats
path: root/publish.sh
diff options
context:
space:
mode:
authoryingyu5658 <i@yingyu5658.me>2025-12-13 08:33:08 +0800
committeryingyu5658 <i@yingyu5658.me>2025-12-13 08:33:08 +0800
commit1e5f8eb33bc41cb59faf059e83701152785cabea (patch)
tree45867273ac2178285be840764f7962d2b55556c6 /publish.sh
downloadblog-1e5f8eb33bc41cb59faf059e83701152785cabea.tar.gz
blog-1e5f8eb33bc41cb59faf059e83701152785cabea.zip
Initial commit
Diffstat (limited to 'publish.sh')
-rw-r--r--publish.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/publish.sh b/publish.sh
new file mode 100644
index 0000000..371276a
--- /dev/null
+++ b/publish.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+#word_counter=$(find ~/blog/content/ -type f -name "*.md" -exec cat {} + | \
+#perl -CSD -pe 's/[\p{P}\p{S}\s\p{M}\p{C}\p{Z}]//g; s/$$.*?$$$$.*?$$//g; s/[*#_\-`~=+|><\^]//g; s/\!$$.*?$$$$.*?$$//g' | \
+#grep -oP '[\p{Han}a-zA-Z]' | \
+#wc -m)
+
+commit_date=$(date +"%Y-%m-%d %H:%M:%S")
+
+if [ "$1" = "-b" ] || [ "$1" = "--blog" ]; then
+ cd ~/blog || exit 1
+ hugo
+ git add .
+ git commit -m "自动提交:$commit_date"
+ echo "pushing hugo-blog-backup"
+ git push origin main
+
+ cd ~/blog/public || exit 1
+ html-minifier index.html --output index.html --collapse-whitespace --remove-comments
+ git add .
+ git commit -m "自动提交:$commit_date"
+ echo "pushing yingyu5658.github.io"
+ git push origin main
+
+elif [ "$1" = "-n" ] || [ "$1" = "--newsgroup" ]; then
+ echo "git clone https://gitee.com/yingyu5658/newsgroup_archives.git"
+ cd ~/blog || exit 1
+ rm -rf newsgroup_archives # Cleanup any existing clone
+ git clone https://gitee.com/yingyu5658/newsgroup_archives.git
+ mv newsgroup_archives/index.html ~/newsgroup_archives/index.html
+ rm -rf newsgroup_archives
+
+ cd ~/newsgroup_archives/ || exit 1
+ git add .
+ git commit -m "$commit_date"
+ echo "pushing newsgroup_archives"
+ git pull origin main # Pull latest changes before pushing
+ git push origin main
+
+else
+ echo "No argument!"
+ exit 1
+fi
+
+
+cd ~/blog || exit 1
+echo "========="
+echo "操作完成!"