-
Notifications
You must be signed in to change notification settings - Fork 1
/
_deploy.sh
executable file
·54 lines (44 loc) · 1.47 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
#!/bin/bash
# Figure out where the files are going
USER="kevin"
REMOTE="columbiafsae.org"
PRODUCTION=false
if [ $# -eq 1 ] && [ $1 == "production" ]; then
PRODUCTION=true
fi
if [ "$PRODUCTION" == true ]; then
REMOTE_DIR="/var/www/columbiafsae.org/"
else
REMOTE_DIR="/var/www/beta.columbiafsae.org/"
fi
# Build the site
# This should use incremental builds when that feature comes out
echo "Regenerating site..."
jekyll build > /dev/null
# Note the current git version & branch
git describe --abbrev --dirty --always >> _site/version
git rev-parse --abbrev-ref HEAD >> _site/version
# Minify site
if [ "$PRODUCTION" == true ]; then
yui-compressor -o '.css$:.css' _site/css/*.css
yui-compressor -o '.js$:.js' _site/js/*.js
# Regex to remove leading tabs and spaces
sed -i "" -e "s/^[ ]*//g" -e "/^$/d" `find _site -type f -name '[^.]*.svg' -o -name '[^.]*.html'`
fi
# Confirm the user wants to deploy
if [ "$PRODUCTION" == true ]; then
echo ">> Deploying to PRODUCTION <<"
echo -ne "Check the contents of _site/. Press return to deploy! "
read
fi
# Sync files to staging area
echo "Copying files to $REMOTE:$REMOTE_DIR..."
ssh $USER@$REMOTE "mkdir -p $REMOTE_DIR/staging/"
rsync -av --delete --exclude ".*" _site/ $USER@$REMOTE:$REMOTE_DIR/staging/ > /dev/null
# Switch over to the new site
echo "Moving files into place..."
ssh $USER@$REMOTE "cd $REMOTE_DIR && \
mv public_html public_html.old && \
mv staging public_html && \
mv public_html.old staging"
echo "Done!"