Wednesday, 15 July 2015

ruby on rails - Capistrano: Check if a folder in Git has changed? -



ruby on rails - Capistrano: Check if a folder in Git has changed? -

our app (1 repo) has rails backend , angular frontend. such, deployment process has npm install, bower install, grunt build --force @ point. problem takes long time deploy, since these commands still executed though updating rails-related things.

is there kind of hook can check if folder containing frontend code has changes, npm install? or should split repo 2 repos own deploy processes each?

apistrano-faster-assets plugins enables such functionality plain rails assets.

you might want check core task see how that's done , adapt or copy-paste code use.

here's effort extract relevant steps , provide more comments:

class precompilerequired < standarderror; end begin # previous release latest_release = capture(:ls, '-xr', releases_path).split[1] # precompile if first deploy raise precompilerequired unless latest_release # create 'pathname' object latest_relase latest_release_path = releases_path.join(latest_release) # execute raises if there 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") # re-create on of assets lastly 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

ruby-on-rails capistrano capistrano3

No comments:

Post a Comment