forked from philipwalton/solved-by-flexbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
67 lines (47 loc) · 1.54 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require "rubygems"
require "rake"
require 'fileutils'
desc "Load a local server and watch for any changes"
task :preview, :port do |t, args|
port = args.port || 4000
annotate "Starting server on port #{port} and watching for changes."
jekyll_pid = Process.spawn("jekyll serve -w --drafts --port #{port}")
compass_pid = Process.spawn("compass watch")
trap("INT") {
[jekyll_pid, compass_pid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
exit 0
}
[jekyll_pid, compass_pid].each { |pid| Process.wait(pid) }
end
desc "Compile and generate all site files"
task :generate do
annotate "Compiling Sass"
system "compass compile ."
annotate "Generating site files"
system "jekyll build"
end
task :deploy => [:generate] do
annotate "Updating gh-pages branch"
# Create a temp repo to pull the latest remote gh-pages files from
mkdir "_tmp"
cd "_tmp" do
system "git init"
system "git remote add origin [email protected]:philipwalton/solved-by-flexbox.git"
system "git pull origin gh-pages"
system "rm -rf *" # remove all files
system "cp -r ../_site/ ./" # copy over all the newly deployed files
system "git add . && git add -u"
system "git commit -m 'Site deployed at #{Time.now.utc}'"
system "git branch -m gh-pages"
system "git push origin gh-pages"
end
annotate "Cleaning up"
# Remove the `_site` and `_tmp` directories, destroy the temp repo
rm_rf "_site"
rm_rf "_tmp"
annotate "Successfully deployed site!"
end
private
def annotate(text)
puts "\n### #{text} ###\n\n"
end