-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-app
executable file
·47 lines (37 loc) · 1.16 KB
/
deploy-app
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
#!/bin/bash -e
ROOT=/var/fauxroku
APP=$1
HASH=$2
APP_DIR=$ROOT/apps/$APP
CACHE_DIR=$APP_DIR/cache
BUILD_DIR=$APP_DIR/build/$HASH
mkdir -p $BUILD_DIR
mkdir -p $CACHE_DIR
export GIT_DIR=$HOME/$APP.git
export GIT_WORK_TREE=$BUILD_DIR
echo "-----> Checking out new code to $BUILD_DIR"
git checkout -q slug 2>/dev/null || git checkout -q --orphan slug
sudo rm -rf $BUILD_DIR/*
git checkout -fq $HASH -- .
cd $ROOT/buildpacks
echo "-----> Detecting build type"
for BP in *
do cd $ROOT/buildpacks/$BP
bin/detect $BUILD_DIR || continue
bin/compile $BUILD_DIR $CACHE_DIR
bin/release $BUILD_DIR > $BUILD_DIR/.release
break
done
echo "-----> Exporting foreman config"
touch $APP_DIR/config
rm $APP_DIR/current
ln -s $BUILD_DIR $APP_DIR/current
cd $APP_DIR/current
sudo foreman export upstart ./.init -u root -a $APP -t $ROOT/deploy/upstart -l $APP_DIR/log -e $APP_DIR/config >/dev/null
RELEASE=`git rev-list --count slug 2>/dev/null || echo 0`
echo "-----> Building slug #$RELEASE"
git add --all
git commit -q -m "Release #$RELEASE from $HASH" --allow-empty
git tag slug-$RELEASE
git log slug-$RELEASE -1 --format=tformat:" %ad | %h | %s"
echo "-----> Slug is ready for deployment"