mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-02-07 09:19:00 +00:00
Create deployment scripts
This commit is contained in:
parent
2df257b07a
commit
a118ec7674
37
deploy.sh
Normal file
37
deploy.sh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Deploys the Hugo build into GitHub Pages.
|
||||||
|
|
||||||
|
# ANSI color codes
|
||||||
|
red="\u001b[31m"
|
||||||
|
green="\u001b[32m"
|
||||||
|
reset="\u001b[0m"
|
||||||
|
|
||||||
|
error_log() {
|
||||||
|
printf "$red An error occurred on line $1.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
target_branch="gh-pages"
|
||||||
|
default_branch="master"
|
||||||
|
|
||||||
|
trap 'error_log $LINENO' ERR
|
||||||
|
|
||||||
|
# Cleaning up the build site
|
||||||
|
printf "Deleting older version of the site"
|
||||||
|
rm -rf public/
|
||||||
|
mkdir public/
|
||||||
|
|
||||||
|
git worktree prune
|
||||||
|
rm -rf .git/worktrees/public/
|
||||||
|
|
||||||
|
# Building the site
|
||||||
|
printf "Building the site"
|
||||||
|
hugo
|
||||||
|
|
||||||
|
# Pushing the build into the pages branch
|
||||||
|
printf "$green -> Deploying page to GitHub...$reset\n"
|
||||||
|
cd public
|
||||||
|
git add --all
|
||||||
|
git commit -m "Deploying site to branch $target_branch."
|
||||||
|
|
||||||
|
git push origin $target_branch
|
38
first-time-setup.sh
Normal file
38
first-time-setup.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Deploys the Hugo build into GitHub Pages.
|
||||||
|
|
||||||
|
# ANSI color codes
|
||||||
|
red="\u001b[31m"
|
||||||
|
green="\u001b[32m"
|
||||||
|
reset="\u001b[0m"
|
||||||
|
|
||||||
|
error_log() {
|
||||||
|
printf "$red An error occurred on line $1.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
target_branch="gh-pages"
|
||||||
|
default_branch="master"
|
||||||
|
|
||||||
|
printf "$green -> Setting up first time things...$reset\n"
|
||||||
|
|
||||||
|
trap 'error_log $LINENO' ERR
|
||||||
|
|
||||||
|
# Creating orphan branch for the site
|
||||||
|
git checkout --orphan $target_branch
|
||||||
|
|
||||||
|
# Reset the branch while retaining the files
|
||||||
|
git reset --hard
|
||||||
|
|
||||||
|
# Initialize the branch
|
||||||
|
git commit --allow-empty -m "Initializing $target_branch branch"
|
||||||
|
|
||||||
|
# Pushing the branch into origin
|
||||||
|
git push origin $target_branch
|
||||||
|
git checkout $default_branch
|
||||||
|
|
||||||
|
# Cleaning up the build site first
|
||||||
|
rm -rf public
|
||||||
|
|
||||||
|
# Adding a worktree for the target branch and setting it to origin
|
||||||
|
git worktree add -B $target_branch public/ origin/$target_branch
|
Loading…
Reference in New Issue
Block a user