-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
78 lines (69 loc) · 2.09 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
68
69
70
71
72
73
74
75
76
77
78
# Graciously borrowed from: https://github.com/davidensinger/davidensinger.github.io/blob/source/Rakefile
desc "Delete _site/"
task :delete do
puts "\## Deleting _site/"
status = system("rm -r _site")
puts status ? "Success" : "Failed"
end
desc "Preview _site/"
task :preview do
puts "\n## Opening _site/ in browser"
status = system("open http://0.0.0.0:4000/")
puts status ? "Success" : "Failed"
end
namespace :build do
desc "Build _site/ for development"
task :dev do
puts "\n## Starting Jekyll"
pids = [
spawn("jekyll serve -w")
]
trap "INT" do
Process.kill "INT", *pids
exit 1
end
loop do
sleep 1
end
end
desc "Build _site/ for production"
task :pro do
puts "\n## Building Jekyll to _site/"
status = system("jekyll build")
puts status ? "Success" : "Failed"
end
end
desc "Commit _site/"
task :commit do
puts "\n## Staging modified files"
status = system("git add -A")
puts status ? "Success" : "Failed"
puts "\n## Committing a site build at #{Time.now.utc}"
message = "Build site at #{Time.now.utc}"
status = system("git commit -m \"#{message}\"")
puts status ? "Success" : "Failed"
puts "\n## Pushing commits to remote"
status = system("git push origin develop")
puts status ? "Success" : "Failed"
end
desc "Deploy _site/ to master branch"
task :deploy do
puts "\n## Deleting master branch"
status = system("git branch -D master")
puts status ? "Success" : "Failed"
puts "\n## Creating new master branch and switching to it"
status = system("git checkout -b master")
puts status ? "Success" : "Failed"
puts "\n## Forcing the _site subdirectory to be project root"
status = system("git filter-branch --subdirectory-filter _site/ -f")
puts status ? "Success" : "Failed"
puts "\n## Switching back to develop branch"
status = system("git checkout develop")
puts status ? "Success" : "Failed"
puts "\n## Pushing all branches to origin"
status = system("git push --all origin")
puts status ? "Success" : "Failed"
end
desc "Commit and deploy _site/"
task :commit_deploy => [:commit, :deploy] do
end