Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rietta
Created October 9, 2012 15:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rietta/3859566 to your computer and use it in GitHub Desktop.
Save rietta/3859566 to your computer and use it in GitHub Desktop.
Capistrano Pre-compile Assets Locally and Deploy through Git
#
# One solution for deploying assets to production servers through git while
# precompiling the assets on the local development system.
#
# By Frank Rietta
# Copyright 2012 Rietta Inc. All Rights Reserved.
# Licensed as open source under terms of the BSD license.
#
# The script switches to the deploy branch, syncs it down, merges the changes from master, precompiles the
# assets and then pushes those to the deploy branch on remote so that the capistrano script can deploy the
# latest code.
#
namespace :preflight do
task :prepare_assets_in_git do
%x{bundle update}
%x{git checkout deploy}
%x{git pull origin deploy}
%x{git merge master}
%x{bundle exec rake assets:precompile}
%x{git add .}
%x{git commit -m "Automatic deployment"}
%x{git push origin deploy}
end
end
# ... Your Deploy Code Here ...
# Compile bundle and gems into the vendors/cache directory
before "deploy:update_code", 'preflight:prepare_assets_in_git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment