build: deploy microblog to mirrors

This commit is contained in:
Ming Di Leom 2024-10-06 08:37:19 +00:00
parent e6c9bc5597
commit 3d45602df9
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
2 changed files with 17 additions and 1 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ public/
.deploy*/
bun.lockb
.wrangler/
site/
microblog/

View File

@ -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