Skip to content

Instantly share code, notes, and snippets.

@a2ikm
Created August 5, 2015 12:48
Show Gist options
  • Save a2ikm/9e0d4523b83d633c80e0 to your computer and use it in GitHub Desktop.
Save a2ikm/9e0d4523b83d633c80e0 to your computer and use it in GitHub Desktop.
Cleanup rolled-back-release archives created by capistrano
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