aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2016-04-27 07:39:07 +0200
committerAlban Peignier2016-04-27 07:39:07 +0200
commit63c4406d7a9b1efcccd74dd67c338be48c71b1b8 (patch)
treee8e08ab3198be755305093edc4848e19fb28e1bf
parentb80904b5c4eda55efbb6e344db5894b7ba6e0afc (diff)
downloadchouette-core-63c4406d7a9b1efcccd74dd67c338be48c71b1b8.tar.bz2
Select deploy_dev in ci:deploy according git branch. Refs #802
-rw-r--r--lib/tasks/ci.rake18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake
index b198a374a..bf9d3840f 100644
--- a/lib/tasks/ci.rake
+++ b/lib/tasks/ci.rake
@@ -5,9 +5,25 @@ namespace :ci do
sh "RAILS_ENV=test rake db:migrate"
end
+ def git_branch
+ if ENV['GIT_BRANCH'] =~ %r{/(.*)$}
+ $1
+ else
+ `git rev-parse --abbrev-ref HEAD`.strip
+ end
+ end
+
+ def deploy_envs
+ Dir["config/deploy/*.rb"].map { |f| File.basename(f, ".rb") }
+ end
+
+ def deploy_env
+ git_branch.in?(deploy_envs) ? git_branch : "dev"
+ end
+
desc "Deploy after CI"
task :deploy do
- sh "cap dev deploy"
+ sh "cap #{deploy_env} deploy"
end
desc "Clean test files"