Skip to content

Commit

Permalink
update publish
Browse files Browse the repository at this point in the history
  • Loading branch information
LJHG committed Dec 28, 2024
1 parent 82e0fc1 commit 1563222
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
gitbook build . ../tmp_mysite
if [ $? -ne 0 ]; then
echo "Error: GitBook build failed!"
exit 1
fi

function publish_to()
{
repo_name=$1
cd ../${repo_name}
rm -rf `ls |grep -v .git`
cp -r ../tmp_mysite/* ../${repo_name}
cd ../${repo_name}
target_dir="../${repo_name}"

echo "Target directory: $target_dir"
if [ ! -d "$target_dir" ]; then
echo "Error: Target directory $target_dir does not exist!"
exit 1
fi

cd "$target_dir" || exit

if [ ! -d ".git" ]; then
echo "Error: $target_dir is not a Git repository!"
exit 1
fi

echo "Current working directory: $(pwd)"

rm -rf `ls | grep -v .git`
cp -r ../tmp_mysite/* "$target_dir"

git add -A
git commit -a -m 'update from gitbook'
git commit -m 'update from gitbook'
git push
}

publish_to mysite

rm -rf ../tmp_mysite
rm -rf ../tmp_mysite

0 comments on commit 1563222

Please sign in to comment.