2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-12 16:44:40 +02:00
|
|
|
def domains_for_stage
|
|
|
|
if ENV['DOMAINS'].present?
|
|
|
|
ENV['DOMAINS'].split
|
2018-10-23 18:26:23 +02:00
|
|
|
else
|
2020-08-12 16:44:40 +02:00
|
|
|
raise "DOMAINS is empty. It must be something like DOMAINS='web1.dev web2.dev'"
|
2018-10-19 11:09:57 +02:00
|
|
|
end
|
2018-10-24 10:39:20 +02:00
|
|
|
end
|
2018-10-19 11:09:57 +02:00
|
|
|
|
2018-10-24 14:15:36 +02:00
|
|
|
task :setup do
|
2020-08-12 16:44:40 +02:00
|
|
|
domains = domains_for_stage
|
2018-10-19 11:09:57 +02:00
|
|
|
|
2018-09-20 11:20:23 +02:00
|
|
|
domains.each do |domain|
|
2019-02-06 17:22:14 +01:00
|
|
|
sh "mina setup domain=#{domain}"
|
2018-09-03 18:36:09 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-24 14:15:36 +02:00
|
|
|
task :deploy do
|
2020-08-12 16:44:40 +02:00
|
|
|
domains = domains_for_stage
|
2018-10-24 14:15:36 +02:00
|
|
|
branch = ENV.fetch('BRANCH')
|
2018-09-03 18:36:09 +02:00
|
|
|
|
|
|
|
domains.each do |domain|
|
2018-10-24 14:15:36 +02:00
|
|
|
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
2018-09-20 11:20:23 +02:00
|
|
|
end
|
|
|
|
end
|
2018-12-04 14:42:52 +01:00
|
|
|
|
|
|
|
task :post_deploy do
|
2020-08-12 16:44:40 +02:00
|
|
|
domains = domains_for_stage
|
2018-12-04 14:42:52 +01:00
|
|
|
branch = ENV.fetch('BRANCH')
|
|
|
|
|
|
|
|
sh "mina post_deploy domain=#{domains.first} branch=#{branch}"
|
|
|
|
end
|
2020-05-14 16:11:00 +02:00
|
|
|
|
|
|
|
task :rollback do
|
2020-08-12 16:44:40 +02:00
|
|
|
domains = domains_for_stage
|
2020-05-14 16:11:00 +02:00
|
|
|
branch = ENV.fetch('BRANCH')
|
|
|
|
|
|
|
|
domains.each do |domain|
|
2020-06-23 15:07:39 +02:00
|
|
|
sh "mina rollback service:restart_puma service:reload_nginx service:restart_delayed_job domain=#{domain} branch=#{branch}"
|
2020-05-14 16:11:00 +02:00
|
|
|
end
|
|
|
|
end
|