Last active
August 29, 2015 13:59
-
-
Save SteveBenner/10819858 to your computer and use it in GitHub Desktop.
Rake - upgrade a Ghost blog installation
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check out my informative blog post on this script