Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 48 lines (37 sloc) 1.16 KB
#!/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"