mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-02-14 15:18:59 +00:00
Improve deploy and setup script
This commit is contained in:
parent
5f79866847
commit
1078a3845d
14
deploy.sh
14
deploy.sh
@ -8,21 +8,23 @@ green="\u001b[32m"
|
|||||||
reset="\u001b[0m"
|
reset="\u001b[0m"
|
||||||
|
|
||||||
error_log() {
|
error_log() {
|
||||||
printf "$red An error occurred on line $1.\n"
|
printf "$red An error occurred on line $1\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
target_branch="gh-pages"
|
target_branch="gh-pages"
|
||||||
default_branch="master"
|
default_branch="master"
|
||||||
|
main_remote_alias="origin"
|
||||||
|
build_directory="public/"
|
||||||
|
|
||||||
trap 'error_log $LINENO' ERR
|
trap 'error_log $LINENO' ERR
|
||||||
|
|
||||||
# Cleaning up the build site
|
# Cleaning up the build site
|
||||||
printf "Deleting older version of the site"
|
printf "Deleting older version of the site"
|
||||||
rm -rf public/
|
rm -rf $build_directory
|
||||||
mkdir public/
|
mkdir $build_directory
|
||||||
|
|
||||||
git worktree prune
|
git worktree prune
|
||||||
rm -rf .git/worktrees/public/
|
rm -rf .git/worktrees/$build_directory
|
||||||
|
|
||||||
# Building the site
|
# Building the site
|
||||||
printf "Building the site"
|
printf "Building the site"
|
||||||
@ -30,8 +32,8 @@ hugo
|
|||||||
|
|
||||||
# Pushing the build into the pages branch
|
# Pushing the build into the pages branch
|
||||||
printf "$green -> Deploying page to GitHub...$reset\n"
|
printf "$green -> Deploying page to GitHub...$reset\n"
|
||||||
cd public
|
cd $build_directory
|
||||||
git add --all
|
git add --all
|
||||||
git commit -m "Deploying site to branch $target_branch."
|
git commit -m "Deploying site to branch $target_branch."
|
||||||
|
|
||||||
git push origin $target_branch
|
git push $main_remote_alias $target_branch
|
||||||
|
@ -13,6 +13,8 @@ error_log() {
|
|||||||
|
|
||||||
target_branch="gh-pages"
|
target_branch="gh-pages"
|
||||||
default_branch="master"
|
default_branch="master"
|
||||||
|
main_remote_alias="origin"
|
||||||
|
build_directory="public/"
|
||||||
|
|
||||||
printf "$green -> Setting up first time things...$reset\n"
|
printf "$green -> Setting up first time things...$reset\n"
|
||||||
|
|
||||||
@ -28,11 +30,11 @@ git reset --hard
|
|||||||
git commit --allow-empty -m "Initializing $target_branch branch"
|
git commit --allow-empty -m "Initializing $target_branch branch"
|
||||||
|
|
||||||
# Pushing the branch into origin
|
# Pushing the branch into origin
|
||||||
git push origin $target_branch
|
git push $main_remote_alias $target_branch
|
||||||
git checkout $default_branch
|
git checkout $default_branch
|
||||||
|
|
||||||
# Cleaning up the build site first
|
# Cleaning up the build site first
|
||||||
rm -rf public
|
rm -rf $build_directory
|
||||||
|
|
||||||
# Adding a worktree for the target branch and setting it to origin
|
# Adding a worktree for the target branch and setting it to origin
|
||||||
git worktree add -B $target_branch public/ origin/$target_branch
|
git worktree add -B $target_branch $build_directory $main_remote_alias/$target_branch
|
||||||
|
Loading…
Reference in New Issue
Block a user