Deploying a Git subdirectory in Capistrano

前端 未结 11 1293
梦谈多话
梦谈多话 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:35

    You can have two git repositories (client and server) and add them to a "super-project" (app). In this "super-project" you can add the two repositories as submodules (check this tutorial).

    Another possible solution (a bit more dirty) is to have separate branches for client and server, and then you can pull from the 'server' branch.

    0 讨论(0)
  • 2020-12-07 09:36

    Looks like it's also not working with codebasehq.com so I ended up making capistrano tasks that cleans the mess :-) Maybe there's actually a less hacky way of doing this by overriding some capistrano tasks...

    0 讨论(0)
  • 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)
    
    0 讨论(0)
  • dont know if anyone is still interested on this. but just letting you guys if anyone is looking for an answer. now we can use: :repo_tree

    https://capistranorb.com/documentation/getting-started/configuration/

    0 讨论(0)
  • 2020-12-07 09:42

    This has been working for me for a few hours.

    # Capistrano assumes that the repository root is Rails.root
    namespace :uploads do
      # We have the Rails application in a subdirectory rails_app
      # Capistrano doesn't provide an elegant way to deal with that
      # for the git case. (For subversion it is straightforward.)
      task :mv_rails_app_dir, :roles => :app do
        run "mv #{release_path}/rails_app/* #{release_path}/ "
      end
    end
    
    before 'deploy:finalize_update', 'uploads:mv_rails_app_dir'
    

    You might declare a variable for the directory (here rails_app).

    Let's see how robust it is. Using "before" is pretty weak.

    0 讨论(0)
提交回复
热议问题