run bundle and migration in Automatic deploy with Git

sudo nano hooks/post-receive

#!/bin/bash
while read oldrev newrev ref
do
    if [[ $ref =~ .*/master$ ]];
    then
        echo "Master ref received.  Deploying master branch to production..."
        git --work-tree=/home/ec2-user/ywrstaging/ywroom-staging --git-dir=/home/ec2-user/proj checkout -f
      # sudo  /etc/init.d/nginx restart
       cd /home/ec2-user/ywrstaging/ywroom-staging &&  source ~/.rvm/scripts/rvm && bundle install && rake db:migrate
       sudo  /etc/init.d/nginx restart


    else
        echo "Ref $ref successfully received.  Doing nothing: only the master branch may be deployed on this server."
    fi
done

Comments

Popular Posts

How to pass hash in Postman

nginx: unrecognized service

Bootstrap Select Picker append add new item if search not exist

Reading Excel Sheets using "Roo" gem in ruby on rails

Add CORS to Nginx on AWS Elastic Beanstalk

Enable gzip compression on Elastic Beanstalk with nginx

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Get video duration by URL in Ruby on Rails

site-enables nginx setting in ruby in rails