-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
61 lines (50 loc) · 1.88 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
require "rubygems"
require "tmpdir"
require "bundler/setup"
require "jekyll"
require 'html-proofer'
# Change your GitHub reponame
GITHUB_REPONAME = "uqbar-project/wiki"
DEST_BRANCH = "gh-pages"
SOURCE_BRANCH = "master"
desc "Generate blog files"
task :generate do
Jekyll::Site.new(Jekyll.configuration({
"source" => ".",
"destination" => "_site"
})).process
end
desc "Check the generated page with html proofer"
task :test do
begin
HTMLProofer.check_directory("./_site", {:external_only => true,
:parallel => {:in_processes => 6},
:cache => {:timeframe => '2w'},
:typhoeus => {:headers => {"User-Agent" => "Mozilla/5.0 (compatible; My New User-Agent)",
:connecttimeout => 10,
:timeout => 25}},
:url_ignore => ['/wiki/', '/wiki.uqbar.org/']}).run
rescue => e
puts "#{e.class}: #{e.message}"
end
puts "Finished running all tests"
end
desc "Generate and publish blog to gh-pages"
task :publish => [:generate] do
Dir.mktmpdir do |tmp|
puts "Created temporal directory #{tmp}"
cp_r "_site/.", tmp
pwd = Dir.pwd
Dir.chdir tmp
system "git init"
#Create CNAME File
system "echo wiki.uqbar.org > CNAME"
system "git add ."
message = "Site updated at #{Time.now}"
system "git commit -m #{message.inspect}"
system "git remote add origin [email protected]:#{GITHUB_REPONAME}.git"
puts "Pushing to origin #{DEST_BRANCH}"
system "git push -f origin #{SOURCE_BRANCH}:#{DEST_BRANCH}"
Dir.chdir pwd
end
end