Skip to content

Instantly share code, notes, and snippets.

@wonjun27
Forked from zooniverse/aws_bundle.rb
Last active Aug 29, 2015
Embed
What would you like to do?
Capistrano::Configuration.instance(:must_exist).load do
# example execution 'cap bundle_app -s version=HEAD'
desc "Bundle code and push to S3"
task :bundle_app do
puts "Starting Git archive of #{version}"
`git archive -o oldweather.tar #{version}`
`gzip oldweather.tar`
s3_upload
clean_up
end
desc "Upload file to S3"
task :s3_upload do
# need to have the aws/s3 gem
AWS::S3::Base.establish_connection!(
:access_key_id => 'YOURACCESSID',
:secret_access_key => 'YOURSECRETKEY'
)
# upload the new one
print "Uploading new one..."
AWS::S3::S3Object.store('oldweather_new.tar.gz', open('oldweather.tar.gz'), 'your-bucket')
print "done\n"
# rename the old file
puts "Renaming old code bundle"
AWS::S3::S3Object.rename "oldweather.tar.gz", "oldweather-#{Time.now.strftime('%H%M-%d%m%y')}.tar.gz", "your-bucket"
# rename the new file
AWS::S3::S3Object.rename "oldweather_new.tar.gz", "oldweather.tar.gz", "your-bucket"
end
desc "Clean up old files"
task :clean_up do
puts "Cleaning up"
`rm oldweather.tar.gz`
puts "All done!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment