Rake tasks for pushing stuff to S3. Heavily cribbed from Mixbook's S3 Deployer. Unlike Mixbook's thing, this does no versioning or fancy revisiony stuff.
Add this line to your application's Gemfile:
gem 's3deploy', git: 'https://github.com/ryanmark/s3deploy-ruby.git'
And then execute:
$ bundle install
Your Rakefile should look something like this:
require'rubygems'require'bundler'Bundler.setuprequire's3deploy/tasks'S3deploy.configuredobucket"my-staging-bucket"app_path"devastator"# dir in the S3 bucket to deploy todist_dir"dist"# local dir to deploy fromgzip[/\.js$/,/\.css$/,/\.json$/,/\.html$/,/\.csv$/]# or just use 'true' to gzip everythingbefore_deploy->do# Some custom code to execute before deployendafter_deploy->do# Some custom code to execute after deployend# You also can specify environment-specific settings, the default environment is 'production'environment(:production)dobucket"my-production-bucket"endaccess_key_idENV['AWS_ACCESS_KEY_ID']secret_access_keyENV['AWS_SECRET_ACCESS_KEY']endTo actually deploy:
$ rake s3:deploy
To deploy to production:
$ ENV=production rake s3:deploy
You can also use the deployer in your own code as a plain old object.
require's3deploy/deployer'deployer=S3deploy::Deployer.new(# requireddist_dir: 'upload',bucket: 'my-bucket',# optionalaccess_key_id: 'AWS access key id',secret_access_key: 'AWS access key',app_path: 'graphics/foo',gzip: [/\.js$/,/\.css$/,/\.html?$/],logger: Rails.logger)- Fork it ( https://github.com/ryanmark/s3deploy/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request