I have been using assembla's SSH deployment tool to setup the automated deployment. What i have done so far is:
- Setup a git repo with two branch
master
anddevelop
. - Setup a SSH script using the following code to deploy on server.
nohup sh -c 'cd /path/to/site && git pull' 2>&1 | tee /tmp/log.out
- I have setup this script to run manually and its working fine. As my commits are properly deploying upon the script run on the server.
But, I have two different directories on server for staging and production site and I want this script to detect the branch and deploy changes accordingly to the staging/production server directory. So basically,
- If I have pushed the changes into the master branch then script should run and deploy the code into the server production directory or take a git pull there through the script commands.
- If I have pushed the changes into the develop branch then script should run and deploy the code into the server staging directory or take a git pull there through the script commands.
The problem is assembla doesn't provide an option to invoke the script based on the specific repo branch and if I use the existing setup then on committing code to any branch of repo will invoke the script.
Could someone help me setup this correctly!