卡普斯特拉诺:检查Git中的文件夹是否已更改? [英] Capistrano: Check if a folder in Git has changed?

查看:17
本文介绍了卡普斯特拉诺:检查Git中的文件夹是否已更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

是否有某种挂钩以便我可以检查if the folder containing frontend code has changes, then npm install?或者我们是否应该将Repo拆分为两个Repos,每个Repos都有自己的部署流程?

推荐答案

apistrano-faster-assets插件为纯Rails资产启用此类功能。

您可能希望选中core task to see how that's done并调整或复制粘贴代码以供您使用。

以下是我仅摘录相关步骤并提供更多注释的尝试:

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

这篇关于卡普斯特拉诺:检查Git中的文件夹是否已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆