From 7a0f43e965b137fe57b30875421396ea6f025d52 Mon Sep 17 00:00:00 2001 From: app-harry Date: Sun, 27 Oct 2024 20:48:10 +0800 Subject: [PATCH] update deploy.sh --- deploy.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/deploy.sh b/deploy.sh index 5e692be2..d904e073 100755 --- a/deploy.sh +++ b/deploy.sh @@ -16,22 +16,26 @@ init() { build() { # Run the Ruby script to generate the output bundle exec ruby "./scaffold.rb" - - # Move all generated files to the root directory - mv ./_output/* ./ } setup_gh() { - # Delete the branch if it exists, and create a new one if git show-ref --verify --quiet "refs/heads/$PAGES_BRANCH"; then - echo "Branch '$PAGES_BRANCH' exists. Deleting it..." - git branch -D "$PAGES_BRANCH" # Delete the local branch + git checkout -b "$PAGES_BRANCH" else - echo "Branch '$PAGES_BRANCH' does not exist locally. Skipping deletion." + git checkout "$PAGES_BRANCH" fi +} + +flush() { + shopt -s extglob - # Create and switch to the new branch - git checkout -b "$PAGES_BRANCH" + rm -rf !(CNAME|_output) + rm -rf .[^.] .??* !(CNAME|_output) + + shopt -u extglob + + # Move all generated files to the root directory + mv ./_output/* ./ } deploy() { @@ -52,6 +56,7 @@ main() { init # Initialize and validate environment build # Build the site setup_gh # Set up the gh-pages branch + flush deploy # Deploy the site }