【问题标题】:Capistrano: Check if a folder in Git has changed?Capistrano:检查 Git 中的文件夹是否已更改?
【发布时间】:2014-10-08 10:14:45
【问题描述】:

我们的应用程序(1 个 repo)有一个 Rails 后端和一个 Angular 前端。因此,部署过程在某些时候有一个npm install, bower install, grunt build --force。问题是部署需要很长时间,因为即使我们只是更新 Rails 相关的东西,这些命令仍然会执行。

是否有某种钩子可以让我检查if the folder containing frontend code has changes, then npm install?还是我们应该将 repo 分成两个 repo,每个 repo 都有自己的部署过程?

【问题讨论】:

    标签: ruby-on-rails capistrano capistrano3


    【解决方案1】:

    apistrano-faster-assets 插件为普通的 Rails 资产启用了此类功能。

    您可能需要检查core task to see how that's done 并修改或复制粘贴代码以供您使用。

    这是我仅提取相关步骤并提供更多 cmets 的尝试:

    class PrecompileRequired < StandardError; end
    begin
      # get the previous release
      latest_release = capture(:ls, '-xr', releases_path).split[1]
    
      # precompile if this is the first deploy
      raise PrecompileRequired unless latest_release
    
      # create a 'Pathname' object for latest_relase
      latest_release_path = releases_path.join(latest_release)
    
      # execute raises if there is a diff
      execute(:diff, '-Naur', release_path.join('path/to/frontend/code'), latest_release_path.join('path/to/frontend/code')) rescue raise(PrecompileRequired)
    
      info("Skipping asset precompile, no asset diff found")
    
      # copy over all of the assets from the last release
      execute(:cp, '-r', latest_release_path.join('public', fetch(:assets_prefix)), release_path.join('public', fetch(:assets_prefix)))
    
    rescue PrecompileRequired
      # execute compile command here
    end
    

    【讨论】:

      猜你喜欢
      • 2014-05-17
      • 1970-01-01
      • 2018-09-13
      • 2011-04-08
      • 2015-04-29
      • 2013-07-21
      • 2010-11-04
      • 1970-01-01
      • 2012-09-16
      相关资源
      最近更新 更多