Skip to content

Instantly share code, notes, and snippets.

@chrisallenlane
Created September 9, 2012 16:17
Show Gist options
  • Save chrisallenlane/3685370 to your computer and use it in GitHub Desktop.
Save chrisallenlane/3685370 to your computer and use it in GitHub Desktop.
Rakefile accompanying bit.ly/NvF4dD
require 'fileutils'
# specify key files
webroot = '/home/ubuntu/www'
srcroot = '/home/ubuntu/src'
# enumerate the LAMP domains
lamp_domains = {
:example1 => 'example-1.com',
:example2 => 'example-2.com',
:example3 => 'example-3.com',
}
# ---------- Rake tasks begin here ---------- #
namespace :site do
# metaprogram the rake tasks for each LAMP domain
lamp_domains.each do |key, domain|
# each lamp domain will have the following tasks created
namespace key do
# each lamp domain will have the following tasks created
desc "Stages changes on the #{domain} development server."
task :stage do
# update the file structures
puts "Staging changes to development server for #{domain}..."
puts `cd #{srcroot}/#{domain}; git merge dev`
puts "Complete."
end
desc "Deploys changes live to #{domain}."
task :deploy do
# update the file structures
puts "Deploying changes to #{domain}..."
# note: I don't actually have access to this code anymore (I wrote it for a previous employer),
# but it looked something like this. The actual rsync options needed may vary slightly from
# what I remember here, so YMMV.
puts `rsync -av #{srcroot}/#{domain} #{webroot}/#{domain}`
puts "Complete."
end
# clear the w3tc directory if it exists
if File.exists?("/home/ubuntu/www/#{domain}/wp-content/w3tc")
desc "Clears the site's W3 Total Cache files from the server."
task :clear_w3tc_cache do
puts "Clearing #{webroot}/#{domain}/wp-content/w3tc/"
puts `rm -rfv #{webroot}/#{domain}/wp-content/w3tc/*`
puts "Done."
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment