-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·62 lines (50 loc) · 1.51 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
59
60
61
62
#!/bin/bash
#Clean up
rm -r -f ./public/*
find . -name '.DS_Store' -type f -delete
# Build the project, if using a theme, replace with `hugo -t <YOURTHEME>
./hugo_osx/hugo -t hugo-theme-cleanwhite --quiet --cleanDestinationDir --minify --gc
# add CNAME back
echo "blog.gainskills.top" > public/CNAME
# for google AD sense
echo "google.com, pub-5029900143451942, DIRECT, f08c47fec0942fa0" > public/ads.txt
echo "google.com, pub-5029900143451942, DIRECT, f08c47fec0942fa0" > docs/ads.txt
echo "algolia.json" > public/.gitignore
# cp site maps, will remove this later
cp public/robots.txt docs/robots.txt
cp public/sitemap.xml docs/sitemap.xml
# add README/License
cp LICENSE public/LICENSE
cp README.md public/README.md
# function for git, "amend" for the minior fix (gramma, spelling)
changetogit () {
if [ "$1" == "amend" ]
then
git add .
git commit --amend --no-edit
git push -f
else
git add .
git commit -m "$1"
git push
fi
}
# main
if [ "$1" != "testing" ]
then
echo -e "\033[0;32mDeploying updates to Algolia...\033[0m"
npm run algolia
if [ "$1" != "amend" ]
then
git push --recurse-submodules=on-demand
fi
echo -e "\033[0;32mpush changes on submoudle: theme...\033[0m"
cd themes/hugo-theme-cleanwhite
changetogit "$1"
echo -e "\033[0;32mpush changes on submoudle: public...\033[0m"
cd ../../public
changetogit "$1"
echo -e "\033[0;32mAdd changes to current repo....\033[0m"
cd ..
changetogit "$1"
fi