Skip to content

Instantly share code, notes, and snippets.

@agius
Created October 18, 2013 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agius/7037016 to your computer and use it in GitHub Desktop.
Save agius/7037016 to your computer and use it in GitHub Desktop.
Generate static error pages and upload to S3
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