Skip to content

Instantly share code, notes, and snippets.

@kommen
Created July 17, 2012 16:03
Show Gist options
  • Select an option

  • Save kommen/3130297 to your computer and use it in GitHub Desktop.

Select an option

Save kommen/3130297 to your computer and use it in GitHub Desktop.

Revisions

  1. kommen revised this gist Jul 17, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    set :branch, "origin/#{ENV['BRANCH'] || "master"}"

    namespace :assets do
    desc "Precompile rails 3.1 assets"
    task :precompile, :except => { :no_release => true } do
  2. kommen revised this gist Jul 17, 2012. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,10 @@
    end
    end

    namespace :deploy do
    desc "Update the deployed code."
    task :update_code, :except => { :no_release => true } do
    run("cat #{current_path}/REVISION") { |c,s,d| set(:deployed_revision, d[0,7]) }
    run("cd #{current_path}; git fetch origin; git reset --hard #{branch}; git submodule update --init;echo '#{branch}' > #{current_path}/BRANCH; git rev-parse #{branch} > #{current_path}/REVISION")
    end
    end
  3. kommen created this gist Jul 17, 2012.
    12 changes: 12 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    namespace :assets do
    desc "Precompile rails 3.1 assets"
    task :precompile, :except => { :no_release => true } do
    asset_paths = "app/assets lib/assets vendor/assets"
    if !ENV['FORCE_PRECOMPILE'].nil? || capture("cd #{current_path}; git diff-tree --name-only -r #{deployed_revision} HEAD #{asset_paths} | wc -l").strip.to_i > 0
    deploy.precompile_assets
    else
    logger.info "Skipping asset pre-compilation because there were no asset changes"
    end
    end
    end