update deploy.sh
This commit is contained in:
parent
44d3849379
commit
103dd5c136
43
deploy.sh
43
deploy.sh
@ -5,6 +5,11 @@ set -eu # Exit on error or unset variable
|
|||||||
|
|
||||||
PAGES_BRANCH="gh-pages"
|
PAGES_BRANCH="gh-pages"
|
||||||
|
|
||||||
|
SITE_DIR="_output"
|
||||||
|
|
||||||
|
_backup_dir="$(mktemp -d)"
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
# Check if the script is running in a GitHub Actions environment
|
# Check if the script is running in a GitHub Actions environment
|
||||||
if [[ -z ${GITHUB_ACTION+x} ]]; then
|
if [[ -z ${GITHUB_ACTION+x} ]]; then
|
||||||
@ -14,6 +19,11 @@ init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
# clean
|
||||||
|
if [[ -d $SITE_DIR ]]; then
|
||||||
|
rm -rf "$SITE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
# Run the Ruby script to generate the output
|
# Run the Ruby script to generate the output
|
||||||
bundle exec ruby "./scaffold.rb"
|
bundle exec ruby "./scaffold.rb"
|
||||||
}
|
}
|
||||||
@ -26,20 +36,22 @@ setup_gh() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup() {
|
||||||
|
mv "$SITE_DIR"/* "$_backup_dir"
|
||||||
|
mv .git "$_backup_dir"
|
||||||
|
|
||||||
|
if [[ -f CNAME ]]; then
|
||||||
|
mv CNAME "$_backup_dir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
flush() {
|
flush() {
|
||||||
|
rm -rf ./*
|
||||||
|
rm -rf .[^.] .??*
|
||||||
|
|
||||||
shopt -s dotglob nullglob
|
shopt -s dotglob nullglob
|
||||||
|
|
||||||
for item in ./* .[^.]*; do
|
mv "$_backup_dir"/* .
|
||||||
# skip ./_output and CNAME
|
|
||||||
if [[ "$item" != "./_output" && "$item" != "./.git" && "$item" != "./.github" && "$item" != "./CNAME" ]]; then
|
|
||||||
rm -rf "$item"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
shopt -u dotglob nullglob
|
|
||||||
|
|
||||||
# Move all generated files to the root directory
|
|
||||||
mv ./_output/* ./
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deploy() {
|
deploy() {
|
||||||
@ -57,11 +69,12 @@ deploy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
init # Initialize and validate environment
|
init
|
||||||
build # Build the site
|
Build
|
||||||
setup_gh # Set up the gh-pages branch
|
setup_gh
|
||||||
|
backup
|
||||||
flush
|
flush
|
||||||
deploy # Deploy the site
|
deploy
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute the main function
|
# Execute the main function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user