Skip to content

Instantly share code, notes, and snippets.

@danchoi
Last active June 8, 2022 17:41
Show Gist options
  • Select an option

  • Save danchoi/9717390 to your computer and use it in GitHub Desktop.

Select an option

Save danchoi/9717390 to your computer and use it in GitHub Desktop.

Revisions

  1. Daniel Choi revised this gist Mar 23, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,8 @@

    # Set the deploy_dir variable to the path on the production server to
    # deployment directory. The script assumes the deployment directory is a git
    # clone of the codebase from an upstream git repo.
    # clone of the codebase from an upstream git repo. This script also assumes
    # you are using Passenger.

    deploy_dir=~/current # deploy dir

  2. Daniel Choi revised this gist Mar 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ else
    fi

    # Uncomment if using ThinkingSphinx
    # RAILS_ENV=$deploy_dir bundle exec rake ts:rebuild
    # RAILS_ENV=production bundle exec rake ts:rebuild


    # Restart if any new Rails code
  3. Daniel Choi revised this gist Mar 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ deploy_dir=~/current # deploy dir


    echo "=======> Deploying to $deploy_dir <========"
    cd /$deploy_dir && git stash && git pull
    cd $deploy_dir && git stash && git pull

    # Run migrations if any are pulled down
    if find db/migrate -type f -mmin -3 | grep '.*'
  4. Daniel Choi created this gist Mar 23, 2014.
    43 changes: 43 additions & 0 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/bin/bash

    # deploy.sh

    # Put this script on your production server and make it executable with chmod
    # +x.

    # Set the deploy_dir variable to the path on the production server to
    # deployment directory. The script assumes the deployment directory is a git
    # clone of the codebase from an upstream git repo.

    deploy_dir=~/current # deploy dir

    # You then can run deploy.sh remotely with ssh:
    #
    # ssh user@deployserver "~/deploy.sh"


    echo "=======> Deploying to $deploy_dir <========"
    cd /$deploy_dir && git stash && git pull

    # Run migrations if any are pulled down
    if find db/migrate -type f -mmin -3 | grep '.*'
    then
    echo New migrations found
    RAILS_ENV=production bundle exec rake db:migrate
    else
    echo No new migrations
    fi

    # Uncomment if using ThinkingSphinx
    # RAILS_ENV=$deploy_dir bundle exec rake ts:rebuild


    # Restart if any new Rails code
    if find app config lib db/migrate -type f -mmin -3 | grep '.*'
    then
    echo Restarting Rails
    touch tmp/restart.txt
    else
    echo No need to restart
    fi