documented multiple environment config

This commit is contained in:
Derek Watson 2014-02-22 23:09:29 -05:00
parent 83c24d7443
commit a7e90214f2

View file

@ -109,6 +109,56 @@ activate :deploy do |deploy|
end
```
### Multiple Environments
Deploy your site to more than one configuration using environment variables.
```ruby
# config.rb
case ENV['TARGET'].to_s.downcase
when 'production'
activate :deploy do |deploy|
deploy.method = :rsync
deploy.host = "www.example.com"
deploy.path = "/srv/www/production-site"
end
else
activate :deploy do |deploy|
deploy.method = :rsync
deploy.host = "staging.example.com"
deploy.path = "/srv/www/staging-site"
end
end
```
$ TARGET=staging bundle exec middleman deploy
$ TARGET=production bundle exec middleman deploy
Tighten this up with some custom Rake tasks
```ruby
# Rakefile
namespace :deploy do
def deploy(env)
puts "Deploying to #{env}"
exec "TARGET=#{env} bundle exec middleman deploy"
end
task :staging do
deploy :staging
end
task :production do
deploy :production
end
end
```
$ rake deploy:staging
$ rake deploy:production
## Breaking Changes
* `v0.1.0`