forked from badoo/techblog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·42 lines (33 loc) · 942 Bytes
/
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
#!/bin/sh
set -ex
build_version=$1
if [ -z "$build_version" ]; then
echo "Usage: $0 <build_version>"
echo " where build_version is major.minor format"
exit 1
fi
rm -rf _site
archive=techblog-$build_version-site
if [ "$(jekyll -v)" != "jekyll 3.1.6" ]; then
yes|sudo gem uninstall -a jekyll
fi
if [ ! $(which jekyll) ]; then
sudo gem install jekyll -v 3.1.6
fi
if [ ! $(which lessc) ]; then
npm install -g less
fi
jekyll build
#output="$(jekyll build 2>&1 |tee /dev/stderr | grep -E 'syntax error|Warning|Unexpected|less is not installed')"
#if [ ! -z "$output" ]; then
# echo 'Build failed'
# exit 1
#fi
cd _site
tar -czf ../$archive.tgz .
cd ..
HOSTS="mwebstaging1.mlan mwebstaging1.ulan"
for host in $HOSTS; do
scp $archive.tgz $host:
ssh $host "if [ -d $archive ]; then rm -r $archive/*; else mkdir $archive; fi && tar -xmf $archive.tgz -C $archive && sudo -u wwwrun rsync -az --delete $archive/* /local/techblog/"
done