-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·37 lines (29 loc) · 919 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
#!/usr/bin/env bash
# This script allows you to easily and quickly generate and deploy your website
# using Hugo to your personal GitHub Pages repository. This script requires a
# certain configuration, run the `setup.sh` script to configure this. See
# https://hjdskes.github.io/blog/update-deploying-hugo-on-personal-github-pages/
# for more information.
# Set the English locale for the `date` command.
export LC_TIME=en_US.UTF-8
# The commit message.
MESSAGE="Site rebuild $(date)"
msg() {
printf "\033[1;32m :: %s\n\033[0m" "$1"
}
if [[ $(git status -s) ]]; then
msg "The working directory is dirty, please commit or stash any pending changes"
exit 1;
fi
msg "Removing the old website"
pushd public
git rm -rf *
popd
msg "Building the website"
hugo
msg "Pushing the updated \`public\` folder to the \`master\` branch"
pushd public
git add *
git commit -m "$MESSAGE"
popd
git push origin master