generated from the-gophers/go-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugo.sh
93 lines (80 loc) · 2.09 KB
/
hugo.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
[[ -z "${SITE_NAME:-}" ]] && SITE_NAME='1-hugo'
[[ -z "${SITE_BRANCH:-}" ]] && SITE_BRANCH='gh-pages-content'
[[ -z "${SITE_TITLE:-}" ]] && SITE_TITLE='Hello, Hugo!'
[[ -z "${SITE_BASEURL:-}" ]] && SITE_BASEURL='/'
function hugo-install-linux {
echo "installing hugo"
sudo mkdir -p hugo/
VERSION="0.76.5"
curl -L https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_Linux-64bit.tar.gz | tar -zxf - --directory hugo/
sudo mv hugo/hugo /usr/bin/
sudo rm -rf hugo/
hugo version
}
function hugo-new-site {
hugo new site ${SITE_NAME} --force
cd ${SITE_NAME}
# git init
git checkout -b ${SITE_BRANCH}
git clone https://github.com/yihui/hugo-xmin.git themes/hugo-xmin/
rm -rf themes/hugo-xmin/.git/
git add themes/hugo-xmin/
git commit -m "hugo: new site and add themes/hugo-xmin/"
CONFIG=$(cat <<EOF
title = "${SITE_TITLE}"
baseURL = "${SITE_BASEURL}"
theme = "hugo-xmin"
languageCode = "en-us"
[menu]
[[menu.main]]
identifier = "home"
name = "${SITE_TITLE}"
pre = "<i class='fa fa-heart'></i>"
url = ""
weight = 101
[[menu.main]]
identifier = "gophercon"
name = "@GopherCon"
pre = "<i class='fa fa-heart'></i>"
url = "https://twitter.com/GopherCon/"
weight = 102
EOF
)
printf "%s" "$CONFIG" > config.toml
hugo new posts/my-first-post.md
git add .
git commit -m "hugo: add config.toml and first post"
git push -u origin ${SITE_BRANCH}
cd ../
}
function hugo-github-init {
cd ${SITE_NAME}/
git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m "Initializing gh-pages branch"
git push origin gh-pages
git checkout ${SITE_BRANCH}
git worktree add -B gh-pages public origin/gh-pages
cd ../
}
function hugo-github-deploy {
cd ${SITE_NAME}/
if ! test -d public/
then
echo "public/ does not exist. running git worktree add..."
git fetch origin
git worktree add -B gh-pages public origin/gh-pages
fi
rm -rf public/*
hugo
cd public
git add --all
git commit -m "publish"
cd ../
git push origin gh-pages
cd ../
}
function hugo-reset {
git worktree remove hello-gophercon/public
rm -rf hello-gophercon
}