Skip to content

Instantly share code, notes, and snippets.

@piotrbelina
Last active December 14, 2015 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrbelina/5023526 to your computer and use it in GitHub Desktop.
Save piotrbelina/5023526 to your computer and use it in GitHub Desktop.
This is a continous deploy script for crontab.

This is a continous deploy script for crontab. To use it:

  1. Create ~/bin/deploy.sh and copy script. Change mode to executable:
chmod + x ~/bin/deploy.sh
  1. Install crontab
crontab -e
 0 * * * * /home/piotr/bin/deploy.sh
  1. Modify config/deploy.rb and set PROJECT in deploy.sh
  2. Enjoy continous deploy
# http://stackoverflow.com/questions/13145278/deploying-via-capistrano-through-jenkins-ssh-authentication-failed
set :deploy_user, ENV['USER']
server "#{deploy_user}@#{hostname}", :app, :db, :primary => true
#!/bin/bash
PROJECT="/home/piotr/public_html/project"
STAGE="staging"
SSH_AGENT_PID=`pgrep -U $LOGNAME ssh-agent`
for PID in $SSH_AGENT_PID; do
let "FPID = $PID - 1"
FILE=`find /tmp -path "*ssh*" -type s -iname "agent.$FPID"`
export SSH_AGENT_PID="$PID"
export SSH_AUTH_SOCK="$FILE"
done
echo $SSH_AGENT_PID
echo $SSH_AUTH_SOCK
export USER="$LOGNAME"
cd "$PROJECT" && /usr/local/bin/cap $STAGE deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment