Created
October 13, 2010 08:44
-
-
Save mraaroncruz/623701 to your computer and use it in GitHub Desktop.
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
# Part of this borrowed from a jekyll deploy script from the jekyll author. | |
# This assumes sprockets and juicer which will combine your js modules and yui compress them respectively | |
BASE = File.dirname(__FILE__) | |
SRC = "#{BASE}/src" | |
SITE = "#{BASE}/site" | |
JSFILE = "javascript.js" | |
task :default => [:js,:build] | |
desc "Build the site including all dependencies" | |
task :build do | |
sh 'staticmatic build .' | |
end | |
desc "Combine and compress javascript files" | |
task :js, :arg1 do |t,args| | |
puts args.arg1 | |
commands = [ "sprocketize #{SRC}/javascripts/default.js > #{SITE}/javascripts/#{JSFILE}"] | |
if args.arg1 != 'false' | |
commands.push "juicer merge -i #{SITE}/javascripts/#{JSFILE} -o #{SITE}/javascripts/temp.js" | |
commands.push "mv #{SITE}/javascripts/temp.js #{SITE}/javascripts/#{JSFILE}" | |
end | |
c = commands.join(' && ') | |
sh c | |
end | |
desc "Git Push to Origin" | |
task :push do | |
require 'rubygems' | |
require 'highline/import' | |
msg = ask("Commit Message: ") { |q| q.echo = true } | |
commands = [ | |
"git add .", | |
"git commit -a -m \"#{msg}\"", | |
"git push origin master" | |
].join(' && ') | |
sh commands | |
end | |
desc "Deploy and launch on remote server" | |
task :deploy => [:push] do | |
require 'rubygems' | |
require 'highline/import' | |
require 'net/ssh' | |
user = ask("Username: ") { |q| q.echo = true } | |
home = "/home/#{user}" | |
repo = "#{home}/git/#{user}_static.git" | |
tmp = "#{home}/tmp/staticmatic" | |
deploy = "#{home}/#{user}.com/dev/staticmatic" | |
Net::SSH.start("#{user}.com",user) do |ssh| | |
commands = [ | |
"git clone #{repo} #{tmp}", | |
"rm -rf #{deploy}", | |
"mv #{tmp} #{deploy}", | |
"cd #{deploy}", | |
"mkdir site/javascripts", | |
"rake", | |
].join(' && ') | |
ssh.exec commands | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment