Created
March 25, 2014 17:20
-
-
Save hidakatsuya/9766712 to your computer and use it in GitHub Desktop.
Capistrano3 で deploy_via :copy する ref: http://qiita.com/hidakatsuya/items/4d097416516afc229199
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:.unshift File.expand_path(File.dirname(__FILE__) + '/lib') # << 必ず先頭に追加 | |
# Load DSL and Setup Up Stages | |
require 'capistrano/setup' | |
# Includes default deployment tasks | |
require 'capistrano/deploy' | |
# : | |
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zip' | |
Zip.setup do |c| | |
c.unicode_names = true | |
c.on_exists_proc = true | |
c.continue_on_exists_proc = true | |
end | |
namespace :copy do | |
task :check do | |
end | |
task create_release: 'release.zip' do |t| | |
file = t.prerequisites.first | |
on roles(:app) do | |
execute :mkdir, '-p', fetch(:tmp_dir) | |
upload! file, fetch(:tmp_dir) | |
execute :unzip, '-o', "#{fetch(:tmp_dir)}/release.zip", '-d', release_path | |
end | |
File.delete file if File.exists?(file) | |
end | |
file 'release.zip' do |t| | |
release_filename = File.join(Dir.pwd, t.name) | |
Dir.chdir fetch(:copy_dir) do | |
Zip::File.open(release_filename, Zip::File::CREATE) do |zipfile| | |
files = FileList['**/*'] | |
files.exclude(*fetch(:copy_exclude)).each do |file| | |
zipfile.add(file, file) | |
end | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :scm, 'copy' | |
set :copy_dir, '.' | |
set :tmp_dir, '/tmp' | |
set :copy_exclude, [ /\.log$/, %r!^files/.+! ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config/ | |
deploy/ | |
production.rb | |
staging.rb | |
deploy.rb | |
lib/ | |
capistrano/ | |
tasks/ | |
Capifile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config/ | |
deploy/ | |
production.rb | |
staging.rb | |
deploy.rb | |
lib/ | |
capistrano/ | |
tasks/ | |
copy.rb << Add to here! | |
Capifile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :deployment do | |
gem 'capistrano', '~> 3.0', require: false | |
gem 'rubyzip', require: false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment