Skip to content

Instantly share code, notes, and snippets.

@ali-sheiba
Created March 25, 2017 10:07
Show Gist options
  • Save ali-sheiba/6a7355cf7063efd5a103baab6c005d5c to your computer and use it in GitHub Desktop.
Save ali-sheiba/6a7355cf7063efd5a103baab6c005d5c to your computer and use it in GitHub Desktop.
ForcePull : copy yml files from config, remove project, clone and recover config
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
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
chdir APP_ROOT do
tmp_dir = '/tmp/force_pull'
system!("mkdir #{tmp_dir}") unless File.directory?(tmp_dir)
cp_files = %w(database.yml secrets.yml)
# Copy Config
cp_files.each do |f|
system!("cp config/#{f} #{tmp_dir}/")
end
Dir.chdir('..') do
system!('rm -fr jn_api')
system!('git clone REPO LINK HERE')
end
system!('git checkout dev')
system!("cp #{tmp_dir}/* config/")
system!('bin/update')
system!("rm -fr #{tmp_dir}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment