Skip to content

Instantly share code, notes, and snippets.

@lucascaton
Last active June 1, 2022 21:10
Show Gist options
  • Save lucascaton/5118852 to your computer and use it in GitHub Desktop.
Save lucascaton/5118852 to your computer and use it in GitHub Desktop.
#! /bin/bash
create_tag(){
TAG=deployed_at_$(date +"%F_%H-%M")
git tag -m '' -a $TAG
git push --tags
}
quick_deploy(){
echo 'Starting quick deploy...'
create_tag
ssh yourserver.com << 'SSH'
cd /var/rails_apps/app_name
git pull
bundle install --without development test
touch tmp/restart.txt
git describe > public/version
SSH
}
complete_deploy(){
echo 'Starting complete deploy...'
create_tag
ssh yourserver.com << 'SSH'
cd /var/rails_apps/app_name
rm -rf public/assets
git pull
bundle install --without development test
bundle exec rake db:migrate db:seed assets:clean assets:precompile
touch tmp/restart.txt
git describe > public/version
SSH
}
if [ $1 ]; then
if [ "$1" == '-q' ] || [ "$1" == '--quick' ]; then
quick_deploy
else
echo -e 'Usage: script/deploy [OPTIONS]\n\nOptions:\n-q --quick: Deploy without migrations and assets precompile.\n'
fi
else
complete_deploy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment