/
travis_blog_deploy
69 lines (53 loc) · 1.52 KB
/
travis_blog_deploy
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
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# Find the latest script on https://github.com/lobopraveen/praveenlobo.com
#
# Function to git add all commit push (gaacp). Up to two parameters are accepted for commit message
gaacp() {
echo "Updating local repo with latest files..."
git add -A
git commit -m "$1. $2"
if [[ $? -ne 0 ]]; then
echo "ERROR: Local repo commit failed."
exit 1
fi
echo "Pushing the updated repo to GitHub..."
git push origin master
if [[ $? -ne 0 ]]; then
echo "ERROR: git push failed."
exit 1
fi
}
# End Function
if [ $# -ne 1 ]; then
echo -e "ERROR: Missing parameter. \nUsage: $0 \"commit message\""
exit 1
fi
echo "Pulling latest repo from GitHub..."
git pull origin master
if [[ $? -ne 0 ]]; then
echo "ERROR: Repo pull failed."
exit 1
fi
read -p "Do you want to build the site locally? y/n: " localbuild
if [[ $localbuild = "y" || $localbuild = "Y" ]]; then
echo "Local build selected."
echo "Present working directory: " `pwd`
echo "Cleaning up publish directory..."
find docs -mindepth 1 -maxdepth 1 ! -name media -exec rm -rf {} \;
echo "Hugo version: " `hugo version`
echo "Building Hugo site locally..."
hugo
if [[ $? -ne 0 ]]; then
echo "ERROR: Site build failed."
exit 1
fi
gaacp "$1" "[skip ci]"
elif [[ $localbuild = "n" || $localbuild = "N" ]]; then
echo "Remote build selected."
gaacp "$1"
echo "Please remember to pull the latest from the remote repo once the remote build deploys the site."
else
echo "ERROR: Incorrect input supplied."
exit 1
fi