Deploying a sub-folder of a git repository with Capistrano
Sometimes it makes sense to have several Rails applications (or other ruby projects) in a single git repository. For example you might want to fork, tag or track changes on all the projects together (or you might just be too stingy to pay for a bigger Github plan).
The problem is that if you want to deploy just one of the applications to your server, unfortunately Capistrano doesn’t support deploying just sub-folders of git repositories. You can get round this by adapting the deploy_via :remote_cache option.
In the vendor/plugins folder of your project create the following folder structure:
/vendor
|- /plugins
|- /remote_cache_with_project_root
|- /recipes
|- /lib
| |- /capistrano
| |- /recipes
| |- /deploy
| |- /strategy
| |- remote_cache_with_project_root.rb
|- recipe.rb
Here are the contents of the files:
recipe.rb:
remote_cache_with_project_root.rb:
In your project’s deploy.rb file, set remote_cache_with_project_root as the deployment method, and set the name of the subfolder as the project_root option.