Skip to content

Instantly share code, notes, and snippets.

@troex
Created December 2, 2011 08:55
Show Gist options
  • Save troex/1422410 to your computer and use it in GitHub Desktop.
Save troex/1422410 to your computer and use it in GitHub Desktop.
Update rails from git on commits
#!/bin/sh
#
# Update rails from git on commits
# Author: Troex Nevelin <troex@fury.scancode.ru>
cd /home/alex/smartspace_development
if [ -f .update_in_progress ]; then
exit 0 # exit if in progress or error happend
fi
git pull --quiet 2>&1 > .update_in_progress
if [ $? -ne 0 ]; then
echo "ERROR auto updating development at `date`"
cat .update_in_progress
exit 1
fi
LAST_COMMIT=`cat .last_commit`
CURRENT_COMMIT=`git rev-parse HEAD`
if [ "$LAST_COMMIT" = "$CURRENT_COMMIT" ]; then
rm .update_in_progress
#echo "nothing to update"
exit 0 # nothing changed
fi
# updating
echo "Updating `pwd` at `date`"
bundle exec rake db:migrate
/etc/init.d/unicorn.sh restart smartspace-development
echo $CURRENT_COMMIT > .last_commit
rm .update_in_progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment