Created
August 5, 2015 12:48
-
-
Save a2ikm/9e0d4523b83d633c80e0 to your computer and use it in GitHub Desktop.
Cleanup rolled-back-release archives created by capistrano
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
namespace :deploy do | |
desc "List rolled-back-release archives" | |
task :rolled_back_releases do | |
on release_roles(:all) do | |
within deploy_path do | |
archives = capture(:ls, "-xt").split.select do |path| | |
path.start_with?("rolled-back-release-") | |
end | |
if archives.any? | |
archives_str = archives.join(" ") | |
info "rolled back releases: #{archives_str}" | |
end | |
end | |
end | |
end | |
namespace :rolled_back_releases do | |
desc "Remove rolled-back-release archives" | |
task :cleanup do | |
on release_roles(:all) do | |
within deploy_path do | |
archives = capture(:ls, "-xt").split.select do |path| | |
path.start_with?("rolled-back-release-") | |
end | |
if archives.any? | |
archives_str = archives.join(" ") | |
execute :rm, archives_str | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment