Deploying a Git subdirectory in Capistrano

前端 未结 11 1419
梦谈多话
梦谈多话 2020-12-07 09:03

My master branch layout is like this:

/ <-- top level

/client <-- desktop client source files

/server

11条回答
  •  被撕碎了的回忆
    2020-12-07 09:40

    Without any dirty forking action but even dirtier !

    In my config/deploy.rb :

    set :deploy_subdir, "project/subdir"
    

    Then I added this new strategy to my Capfile :

    require 'capistrano/recipes/deploy/strategy/remote_cache'
    
    class RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache
    
      private
    
      def repository_cache_subdir
        if configuration[:deploy_subdir] then
          File.join(repository_cache, configuration[:deploy_subdir])
        else
          repository_cache
        end
      end
    
      def copy_repository_cache
        logger.trace "copying the cached version to #{configuration[:release_path]}"
        if copy_exclude.empty? 
          run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}"
        else
          exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
          run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}"
        end
      end
    
    end
    
    
    set :strategy, RemoteCacheSubdir.new(self)
    

提交回复
热议问题