Created
August 15, 2012 21:20
-
-
Save tscolari/3363770 to your computer and use it in GitHub Desktop.
Octopress S3 Deploy Method
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
# .... | |
gem 'aws-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
# Configuration | |
aws_access_id = "11111" | |
aws_secret_key = "111111" | |
aws_s3_bucket_name = "my.bucket.com" | |
deploy_default = "aws_s3" | |
# ... | |
desc "Deploy website via S3" | |
task :aws_s3 do | |
puts "## Deploying website via AWS S3" | |
require 'aws/s3' | |
AWS::S3::Base.establish_connection!( | |
access_key_id: aws_access_id, | |
secret_access_key: aws_secret_key | |
) | |
AWS::S3::Bucket.find aws_s3_bucket_name | |
ok_failed(Dir["#{public_dir}/**/*"].each do |file| | |
# Exclude directories from copy | |
unless File.directory?(file) | |
print "Uploading #{file}..." | |
AWS::S3::S3Object.store(file.gsub(/^public\//,''), open(file), aws_s3_bucket_name) | |
puts " ok" | |
end | |
end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment