Skip to content

Instantly share code, notes, and snippets.

@D3xx73r
Created October 11, 2013 01:47
Show Gist options
  • Save D3xx73r/6928430 to your computer and use it in GitHub Desktop.
Save D3xx73r/6928430 to your computer and use it in GitHub Desktop.
Deployment using Rails + Git + Bash
#Set the rails environment
export RAILS_ENV=environment
#If app directory is present
if [ -d /some/app/directory ]; then
cd /some/app/directory
#Fetch latest changes from origin and update our local branch
git fetch origin
git reset --hard origin/master
#Installing gems
bundle install
#This is only necesary if you added your database.yml file to your .gitignore
#Also you will need to previously add the database.yml file to a directory in your server
#Copy database configuration file to the right place
cp /path/to/database-to-copy.yml config/database.yml
#If the directory does not exist
else
#First run: we need to clone the repo.
cd /desired/directory
git clone [email protected]:PATH/to.git
cd git_repo
#Installing gems
bundle install
#This is only necesary if you added your database.yml file to your .gitignore
#Also you will need to previously add the database.yml file to a directory in your server
#Copy database configuration file to the right place
cp /path/to/database-to-copy.yml config/database.yml
#Create the database
rake db:create
fi
bundle exec rake db:migrate
#If app's tmp directory exist
#This is only necesary if you're using a web server to serve the app(nginx, apache)
#And passenger as the application server
if [ -d /some/app/directory ]; then
echo "El directorio ya existe"
else
mkdir tmp
fi
#Restart the application process
touch tmp/restart.txt
@D3xx73r
Copy link
Author

D3xx73r commented Oct 11, 2013

Any contributions are welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment