-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
69 lines (62 loc) · 1.92 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
desc "Delete _site/"
task :delete do
puts "\## Deleting _site/"
status = system("rm -r _site")
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_ENV=production jekyll build")
puts status ? "Success" : "Failed"
end
end
desc "Commit _site/"
task :commit => 'build:pro' 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}"
puts "What is the commit message?"
input = STDIN.gets.chomp
message = "#{input}. 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 source")
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 source branch"
status = system("git checkout source")
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