From 3d45602df9dbab071b3a8eac1b2481c99536c24c Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Sun, 6 Oct 2024 08:37:19 +0000 Subject: [PATCH] build: deploy microblog to mirrors --- .gitignore | 2 ++ build.sh | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 84d1a50..acbe28a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ public/ .deploy*/ bun.lockb .wrangler/ +site/ +microblog/ diff --git a/build.sh b/build.sh index 4712e2b..c70e0cf 100644 --- a/build.sh +++ b/build.sh @@ -11,9 +11,23 @@ export PATH="$PATH:./node_modules/.bin" hexo generate -# deploy site assets if [ "$NODE_ENV" = "production" ] && [ -d "public/" ]; then + # deploy site assets git clone --depth 1 --branch site https://gitlab.com/curben/blog.git site cp -r site/* "public/" rm -f "public/README.md" + + # deploy microblog + git clone --depth 1 --branch microblog https://gitlab.com/curben/blog.git microblog + cd "microblog/" + export PATH="$PATH:../node_modules/.bin" + hexo generate + + cat "rsync-include.txt" | while read include; do + find "public/" -path "public/$include" -type f | while read file; do + destdir="../public/$(dirname $file | sed -r 's|^public/?||')" + mkdir -p "$destdir" + cp "$file" "$destdir" + done + done fi