-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
63 lines (48 loc) · 1.14 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
63
#!/bin/bash
# Based on https://github.com/yegor256/jekyll-github-deploy/blob/master/bash/deploy.sh
set -x
set -e
set -o pipefail
URL=$(git config --get remote.origin.url)
BRANCH="gh-pages"
BRANCH_FROM="master"
BUNDLE=""
DRAFTS=$6
SRC=$(pwd)
TEMP=$(mktemp -d -t jgd-XXX)
trap "rm -rf ${TEMP}" EXIT
CLONE=${TEMP}/clone
COPY=${TEMP}/copy
echo ${CLONE}
echo -e "Cloning Github repository:"
git clone -b "${BRANCH_FROM}" "${URL}" "${CLONE}"
cp -R ${CLONE} ${COPY}
cd "${CLONE}"
echo -e "\nBuilding Jekyll site:"
rm -rf _site
jekyll build
if [ ! -e _site ]; then
echo -e "\nJekyll didn't generate anything in _site!"
exit -1
fi
cp -R _site ${TEMP}
cd ${TEMP}
rm -rf ${CLONE}
mv ${COPY} ${CLONE}
cd ${CLONE}
echo -e "\nPreparing ${BRANCH} branch:"
if [ -z "$(git branch -a | grep origin/${BRANCH})" ]; then
git checkout --orphan "${BRANCH}"
else
git checkout "${BRANCH}"
fi
echo -e "\nDeploying into ${BRANCH} branch:"
rm -rf *
cp -R ${TEMP}/_site/* .
rm -f README.md
git add .
git commit -am "new version $(date)" --allow-empty
git push origin ${BRANCH} 2>&1 | sed 's|'$URL'|[skipped]|g'
echo -e "\nCleaning up:"
rm -rf "${CLONE}"
rm -rf "${SITE}"