Last active
January 27, 2018 22:39
-
-
Save Darep/5303361 to your computer and use it in GitHub Desktop.
Super simple Middleman deploy script, uses Rsync over SSH or plain SCP
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: Change the variables, place into your project dir and
rake deploy