Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
out-of-band update: add Heroku deploy task
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrisoxide committed May 25, 2024
1 parent 875f25e commit 87cdb6d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions lib/tasks/deploy.rake
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

0 comments on commit 87cdb6d

Please sign in to comment.