Created
May 6, 2014 14:17
-
-
Save jalberto/0cfc86174f4f7a3307d3 to your computer and use it in GitHub Desktop.
Capistrano 3.1.x Strategy to deploy git projects with subdirectories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# 1. Drop this file into lib/capistrano/remote_cache_with_project_root_strategy.rb | |
# 2. Add the following to your Capfile: | |
# require 'capistrano/git' | |
# require './lib/capistrano/remote_cache_with_project_root_strategy' | |
# 3. Add the following to your config/deploy.rb | |
# set :git_strategy, RemoteCacheWithProjectRootStrategy | |
# set :project_root, 'subdir/path' | |
# Define a new SCM strategy, so we can deploy only a subdirectory of our repo. | |
module RemoteCacheWithProjectRootStrategy | |
include Capistrano::Git::DefaultStrategy | |
def test | |
test! " [ -f #{repo_path}/HEAD ] " | |
end | |
def check | |
test! :git, :'ls-remote -h', repo_url | |
end | |
def clone | |
git :clone, '--mirror', repo_url, repo_path | |
end | |
def update | |
git :remote, :update | |
end | |
def release | |
git :archive, fetch(:branch), fetch(:project_root), '| tar -x -C', release_path, "--strip=#{fetch(:project_root).count('/')+1}" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment