Skip to content

Instantly share code, notes, and snippets.

@Darep
Last active January 27, 2018 22:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darep/5303361 to your computer and use it in GitHub Desktop.
Save Darep/5303361 to your computer and use it in GitHub Desktop.
Super simple Middleman deploy script, uses Rsync over SSH or plain SCP
SSH_USER = 'test'
SSH_HOST = 'example.com'
SSH_DIR = '/home/test/website/releases'
RSYNC = false
desc "Run the preview server at http://localhost:4567"
task :preview do
system("middleman server")
end
desc "Build the website from source"
task :build do
puts "-----> Building website"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end
desc "Build and deploy the website"
task :deploy => :build do
if !ENV["VERSION"]
puts "Please, give a version number, like so: \"rake deploy VERSION=v1\""
next
end
if RSYNC
puts "-----> Deploying website via rsync to #{SSH_HOST}"
status = system("rsync -avze 'ssh' build/ #{SSH_USER}@#{SSH_HOST}:#{SSH_DIR}/#{ENV['VERSION']}")
end
if !RSYNC || !status
puts "-----> Deploying website via scp to #{SSH_HOST}"
status = system("scp -r build/ #{SSH_USER}@#{SSH_HOST}:#{SSH_DIR}/#{ENV['VERSION']}")
end
puts status ? "OK" : "FAILED"
end
# TODO: add task to update the symlink to point to the new release
@Darep
Copy link
Author

Darep commented Aug 27, 2013

Usage: Change the variables, place into your project dir and rake deploy

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