forked from regolith-linux/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·48 lines (36 loc) · 1009 Bytes
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -Eeu -o pipefail
GIT_URL="[email protected]:regolith-linux/regolith-linux.github.io.git"
GIT_REMOTE="${GIT_REMOVE:-origin}"
GIT_BRANCH="${GIT_BRANCH:-master}"
HUGO_ENV="${HUGO_ENV:-production}"
export GIT_URL GIT_REMOTE GIT_BRANCH HUGO_ENV
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
push_git() {
msg="Rebuilding site $(date)"
if [ $# -eq 1 ] ; then
msg="${1}"
fi
# Commit changes.
git commit -m "$msg"
# Push source and build repos.
git push -u "${GIT_REMOTE}" "${GIT_BRANCH}"
git subtree push --prefix public "${GIT_URL}" "${GIT_BRANCH}"
}
# Make sure there are no remnants behind
rm -rf public/*
# Build the project.
hugo
# Set the CNAME
echo "regolith-linux.org" > public/CNAME
# Add changes to git.
git add --all
git diff --staged --stat
while true; do
read -rp "Do you wish to push these changes? " yn
case $yn in
[Yy]* ) push_git "$@"; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done