-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·58 lines (44 loc) · 1.12 KB
/
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
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -e
repo_dir="$( cd "$( dirname "$0" )" && pwd )"
(
cd "$repo_dir"
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
if [ "${branch_name}" != "hugo" ]; then
echo "Can only publish from the main \"hugo\" branch"
exit 1
fi
if [ "$(git status -s)" ]; then
echo "The working directory is dirty. Please commit any pending changes."
exit 1;
fi
echo "Deleting old publication"
rm -rf public
mkdir public
git worktree prune
rm -rf .git/worktrees/public/
echo "Checking out master branch into public"
git worktree add -B master public origin/master
echo "Removing existing files"
(
cd public
git pull
)
rm -rf public/*
echo "Generating site"
hugo
msg="rebuilding site $(date)"
if [ -n "$*" ]; then
msg="$*"
fi
echo "Updating master branch"
(
cd public
git add --all
git commit -m "$msg"
)
echo "Pushing to github"
git push --all
)