Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveBenner/10819858 to your computer and use it in GitHub Desktop.
Save SteveBenner/10819858 to your computer and use it in GitHub Desktop.
Rake - upgrade a Ghost blog installation
require 'bundler'
require 'fileutils'
Bundler.require
GHOST_DIR = ENV['GHOST_HOME'] || '<your_ghost_folder>'
THEME = 'casper'
namespace :blog do
desc 'Upgrades Ghost using given file'
task :upgrade, :file do |t, args|
ghost_archive = args[:file]
abort 'Please specify a .zip package' unless File.extname(ghost_archive) == '.zip'
Dir.chdir GHOST_DIR
`tar cvzf content-backup.tgz content` # backup content files
FileUtils.rm_rf 'core'
Dir.mkdir 'tmp' unless Dir.exist? 'tmp'
Dir.chdir 'tmp' do
`unzip #{ghost_archive}`
files = Dir.glob '*'
FileUtils.cp_r files, GHOST_DIR, remove_destination: true
end
FileUtils.rm_rf 'tmp'
`npm install --production`
puts "Successfully upgraded to ghost version #{/((\d)+\.)+/.match(ghost_archive)[0].chop}!"
end
end
@SteveBenner
Copy link
Author

Check out my informative blog post on this script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment