Created
April 7, 2016 17:05
-
-
Save marano/3482bf594a7e4594c9038bf53bb7fb5b to your computer and use it in GitHub Desktop.
This file contains 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
namespace :eb do | |
def eb_deployer_env | |
ENV["EB_DEPLOYER_ENV"] || "dev" | |
end | |
def eb_deployer_package | |
git_sha = `git log -n1 | awk '/^commit/ {print $2; exit;}' | cut -c 1-10`.strip | |
"tmp/pkg/example_app-#{git_sha}-#{ENV['VERSION_LABEL_SUFFIX']}.zip" | |
end | |
desc "Remove the package file we generated." | |
task :clean do | |
sh "rm -rf tmp/pkg" | |
end | |
desc "Build package for eb_deployer to deploy to a Ruby environment in tmp/pkg directory." | |
task :package => [:clean, :environment] do | |
sh "mkdir -p tmp/pkg" | |
to_exclude = %w(tmp .git coverage .idea .DS_Store).map { |file| "--exclude='*#{file}*'" }.join(' ') | |
sh "bundle exec rake assets:precompile" | |
sh "zip -9 -r #{to_exclude} '#{eb_deployer_package}' ." | |
end | |
desc "Deploy package we built in tmp directory. default to dev environment, specify environment variable EB_DEPLOYER_ENV to override, for example: EB_DEPLOYER_ENV=production rake eb:deploy." | |
task :deploy => [:package] do | |
sh "eb_deploy --package '#{eb_deployer_package}' --environment #{eb_deployer_env}" | |
end | |
desc "Destroy Elastic Beanstalk environments. It won't destroy resources defined in eb_deployer.yml. Default to dev environment, specify EB_DEPLOYER_ENV to override." | |
task :destroy do | |
sh "eb_deploy --destroy --environment #{eb_deployer_env}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment