Created
October 18, 2013 05:48
-
-
Save agius/7037016 to your computer and use it in GitHub Desktop.
Generate static error pages and upload to S3
This file contains hidden or 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 :static do | |
desc "Generate and upload static pages" | |
task :generate do | |
`jekyll build -s jekyll -d jekyll/_site` | |
`cp -r jekyll/_site/* public/` | |
config = YAML.load(File.read(File.join(File.dirname(__FILE__), '..', '..', 'config', 'keys.yml'))) | |
config = config['production']['amazon'] | |
AWS.config(:access_key_id => config['key'], :secret_access_key => config['secret']) | |
s3 = AWS::S3.new | |
bucket = s3.buckets['static.yoursite.com'] | |
bucket.acl = :public_read | |
Dir.chdir "jekyll/_site" do |base| | |
Dir.glob(File.join('**', '*')).each do |file| | |
next unless File.file?(file) | |
obj = bucket.objects[file] | |
obj.write(Pathname.new(file), :acl => :public_read) | |
end | |
end | |
`rm -rf jekyll/_site` | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment