-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_deploy.sh
More file actions
executable file
·35 lines (35 loc) · 950 Bytes
/
_deploy.sh
File metadata and controls
executable file
·35 lines (35 loc) · 950 Bytes
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
#!/bin/bash -e
export PATH="/usr/local/bin:$PATH"
if [ ! -d .git ]
then
LOG_FILE="`mktemp -t jasoncodes_deploy.log.XXXXXX`"
trap '{ rm -f "$LOG_FILE"; }' EXIT
if (
set -e
cd ../repo
git fetch origin
git reset -q --hard origin/master
git clean -qxf
chmod +x _deploy.sh
./_deploy.sh
) > "$LOG_FILE" 2>&1
then
echo Deploy succeeded.
else
echo Deploy failed.
mail -s "jasoncodes.com deploy error" "`whoami`" < "$LOG_FILE"
fi
else
docker build -t jasoncodes.com .
cd ..
[ -e build.tmp ] && rm -rf build.tmp
mkdir build.tmp
docker run --rm jasoncodes.com tar -cf - -C htdocs . | tar -x -C build.tmp
[ -e public_html.new ] && rm -rf public_html.new
[ ! -e public_html ] || rsync --archive public_html/ public_html.new
rsync -rlpgoDO --checksum --delete build.tmp/ public_html.new/
rm -rf build.tmp
[ -e public_html.old ] && rm -rf public_html.old
[ ! -e public_html ] || mv public_html{,.old}
mv public_html{.new,}
fi