Created
July 25, 2017 15:57
-
-
Save andreortiz82/f2f4b996f77b850dbbb931497fdceed4 to your computer and use it in GitHub Desktop.
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
task :deploy do | |
require "aws-sdk" | |
Aws.config.update({ | |
region: 'us-east-1', | |
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']) | |
}) | |
s3 = Aws::S3::Resource.new | |
bucket = s3.bucket(ENV['AWS_BUCKET']) | |
puts "Roboto Build..." | |
puts `bundle exec middleman build` | |
puts "..............................." | |
puts "Roboto Deploy..." | |
puts "..............................." | |
puts "#{bucket.name} files are: " | |
bucket.objects.each do |object| | |
puts "Deleting ..............................." | |
puts "#{object.key} - #{object.etag}" | |
object.delete | |
end | |
Dir.glob("build/**/*.*").each do |file_name| | |
key = file_name.sub("build/","") | |
bucket.object(key).upload_file(file_name) | |
puts "Uploading ..............................." | |
puts "#{key} to #{bucket.name}." | |
end | |
puts "..............................." | |
puts "Roboto is done. Have a nice day." | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment