This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
out-of-band update: add Heroku deploy task
- Loading branch information
1 parent
875f25e
commit 87cdb6d
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :deploy do | ||
HEROKU_STAGING_DEPLOY = <<~BASH | ||
git push -f obsekio-staging staging:master && \ | ||
heroku run rake db:migrate -a obsekio-staging && \ | ||
heroku run rake data:migrate -a obsekio-staging && \ | ||
heroku restart -a obsekio-staging | ||
BASH | ||
|
||
HEROKU_PRODUCTION_DEPLOY = <<~BASH | ||
git push -f obsekio-production master:master && \ | ||
heroku run rake db:migrate -a obsekio-production && \ | ||
heroku run rake data:migrate -a obsekio-production && \ | ||
heroku restart -a obsekio-production | ||
BASH | ||
|
||
def print_warning(deploy_environment) | ||
printf <<~TEXT | ||
\033[31m | ||
WARNING! You are about to deploy to the tool-for-systemic-change '#{deploy_environment}' environment. | ||
\033[0m | ||
TEXT | ||
end | ||
|
||
def print_confirmation(deploy_environment) | ||
print "Are you ready to release to '#{deploy_environment}'? Type 'yes' to continue: " | ||
end | ||
|
||
def confirmed? | ||
STDIN.gets.strip.upcase == 'YES' | ||
end | ||
|
||
desc 'deploy to staging environment' | ||
task :staging do | ||
print_warning('staging') | ||
print_confirmation('staging') | ||
if confirmed? | ||
sh(HEROKU_STAGING_DEPLOY) | ||
else | ||
puts 'Cancelling release.' | ||
end | ||
end | ||
|
||
desc 'deploy to production environment' | ||
task :production do | ||
print_warning('PRODUCTION') | ||
print_confirmation('PRODUCTION') | ||
if confirmed? | ||
sh(HEROKU_PRODUCTION_DEPLOY) | ||
else | ||
puts 'Cancelling release.' | ||
end | ||
end | ||
end |