Skip to content

Instantly share code, notes, and snippets.

@1syo
Last active December 14, 2015 12:48
Show Gist options
  • Save 1syo/5088793 to your computer and use it in GitHub Desktop.
Save 1syo/5088793 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
. $HOME/.bashrc
. $HOME/.rvm/scripts/rvm
NOW=`date "+%Y%m%d%H%M%S"`
# set up target directories
CURRENT_DIR=$HOME/apps/current
RELESE_DIR=$HOME/apps/releases/$NOW
SHARED_DIR=$HOME/apps/shared
# copy to release directory
mkdir -p $RELESE_DIR
git archive master | tar -x -C $RELESE_DIR
rm $CURRENT_DIR/tmp
rm $CURRENT_DIR/log
rm $CURRENT_DIR
ln -s $RELESE_DIR $CURRENT_DIR
ln -s $SHARED_DIR/log $CURRENT_DIR/log
ln -s $SHARED_DIR/tmp $CURRENT_DIR/tmp
# copy to config files (optional)
cp $SHARED_DIR/config/database.yml $CURRENT_DIR/config/database.yml
cp $SHARED_DIR/config/unicorn.rb $CURRENT_DIR/config/unicorn.rb
# bundle
cd $CURRENT_DIR
rvm use 1.9.2-p180@project_name
bundle install
bundle exec rake db:migrate:reset RAILS_ENV=inhouse
# unicorn restart
$HOME/bin/unicorn restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment