-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·42 lines (39 loc) · 1.07 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
#!/bin/bash
### Set the following variables for your repository
GITHUBUSERNAME=jdmar3
REPONAME=inls161
REMOTEADDR=github.com
REMOTEUSERNAME=git
BUILDBRANCH=gh-pages
WORKDIR=~/workspace/inls161 # Local directory of source repo
### Display help text
if [[ "$1" = [-][hH] || "$1" = [-][hH] || "$1" = [-][-][Hh][Ee][Ll][Pp] ]]
then
echo -e "Usage: deploy.sh [source branch] [target branch]"
echo -e "Example: deploy.sh"
echo -e
echo -e "This script should be run in the directory where your Jekyll source files live."
echo -e
echo -e " -h, --help Displays this help screen. "
exit 0
fi
TEMPDIR=`mktemp -d`
# move into $TEMPDIR
cd $TEMPDIR
# Clone repository into TEMPDIR
git clone --single-branch --branch=$BUILDBRANCH $REMOTEUSERNAME@$REMOTEADDR:$GITHUBUSERNAME/$REPONAME.git $TEMPDIR
# Build Jekyll site
jekyll build -s $WORKDIR -d $TEMPDIR
# Add new build to git
git add -v .
# Commit changes since last build
git commit -a -m "Update live site `date`"
# Push changes
git push
# Clear temp dir
cd ..
rm -rf $TEMPDIR
# Move back to source dir
cd $WORKDIR
# Exit
exit 0