Created
January 19, 2011 01:00
-
-
Save kerrizor/785481 to your computer and use it in GitHub Desktop.
Rake task to build sitemap and deploy to S3
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
desc "build and deploy sitemap" | |
task :refresh_sitemap => :environment do | |
s3_credentials = YAML.load_file("#{Rails.root.to_s}/config/amazon_s3.yml")[Rails.env].symbolize_keys! | |
# builds the sitemap and deploys to S3 without notifying search engines | |
Rake::Task["sitemap:refresh:no_ping"].invoke | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => s3_credentials[:access_key_id], | |
:secret_access_key => s3_credentials[:secret_access_key] | |
) | |
Dir.glob("tmp/*xml.gz").each do |f| | |
filename = File.join(Rails.root, f) | |
AWS::S3::S3Object.store(File.basename(filename), open(filename), s3_credentials[:bucket], :access => :public_read) | |
puts " [uploaded to S3:#{s3_credentials[:bucket]}]" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment