-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
66 lines (56 loc) · 1.57 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
# coding: utf-8
deploy_dir = "_deploy"
deploy_branch = "gh-pages"
config_files = Dir.glob("_config/*.yml").join(",")
ROOT = File.expand_path('.')
require 'rubygems'
begin
require 'colored'
rescue LoadError
raise 'You must "gem install colored" to use terminal colors'
end
desc "generate site"
task :generate do
puts("Generating static site into _deploy")
puts config_files
system("jekyll build --config #{config_files}")
end
desc "deploy site"
task :deploy do
puts "Getting ready to deploy."
if Dir["#{deploy_dir}"].empty?
system("mkdir #{deploy_dir}")
end
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
puts "Generating site from source."
cd "#{deploy_dir}" do
system("git init")
system("git remote add origin [email protected]:teamleada/blog.git")
system("git pull")
system("git checkout -b gh-pages")
system("git checkout -f gh-pages")
end
Rake::Task[:generate].execute
cd "#{deploy_dir}" do
system("git add . --all")
system("git add -u")
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{deploy_dir} website"
system "git push origin #{deploy_branch} --force"
puts "\n## Github Pages deploy complete"
end
end
desc "Starts the server to serve files locally"
task :jekyll do
puts "Starting jekyll server."
puts "Config files:"
puts config_files
sys("jekyll server --config #{config_files} --watch --port 4002")
end
def sys(cmd)
puts ("> "+cmd).blue
system(cmd)
end
task default: :jekyll