Commit 89c32874 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider

Merge branch 'chore/add_simple_easy_deploy_scripts_to_bin' into 'develop'

Chore/add simple easy deploy scripts to bin

See merge request !925
parents 6f556ee6 92c5a3ed
Pipeline #36184 passed with stage
in 40 minutes and 29 seconds
#!/usr/bin/env bash
bundle exec cap production deploy
#!/usr/bin/env bash
bundle exec cap staging deploy
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
require 'yaml'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
def production_db?
db_config = YAML.load_file('config/database.yml')['development']
return unless db_config
db_user = " --username=#{db_config['username']} " if db_config['username']
db_host = " --host=#{db_config['hostname']} " if db_config['hostname']
`psql #{db_config['database']}#{db_user}#{db_host} -c 'SELECT value FROM ar_internal_metadata;'`.include?('production')
end
def ask_enforce_db_drop
puts "\nIt seems you have a production db on your development machine"
puts "\nDo you want to enforce dropping it with DISABLE_DATABASE_ENVIRONMENT_CHECK=1 ?\n\nAnswer (y/n): "
prompt = STDIN.gets.chomp
if prompt == 'y'
puts "\n== Dropping and re-creating the Database =="
system!('DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bin/rails db:drop')
else
puts "\n== Production db can't be dropped =="
exit
end
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts 'Bundling the project'
system('bundle check') || system!('bundle install')
if production_db?
ask_enforce_db_drop
else
puts "\n== Dropping and re-creating the Database =="
system('bin/rails db:drop')
end
system! 'bin/rails db:create'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Loading the DB-Schema =="
system! 'bin/rails db:schema:load'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment