forked from Azure/azure.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
56 lines (47 loc) · 1.24 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
require 'rubygems'
require 'tmpdir'
require 'bundler/setup'
require 'jekyll'
GITHUB_REPONAME = 'Azure/azure.github.io.git'
def silent_interrupt
begin
yield
rescue Interrupt
# ignored
end
end
def run(cmd, options = {})
puts "running: #{cmd}" unless options.has_key?(:q) && options[:q]
result = system(cmd)
exit(1) if result == false
result
end
desc 'Generate azure.github.io files'
task :build do
silent_interrupt { system 'npm install && gulp build' }
end
task :serve do
Dir.chdir('jekyll') do
silent_interrupt { system 'jekyll serve' }
end
end
task :test => [:build] do
proofer = HTML::Proofer.new('./_site')
proofer.run
exit(1) if !proofer.failed_tests.empty?
end
desc 'Generate and publish blog to gh-pages'
task :publish => [:build] do
Dir.mktmpdir do |tmp|
cp_r './_site/.', tmp
Dir.chdir tmp do
run('git init')
run('git config user.name "Travis CI"')
run('git config user.email "[email protected]"')
run('git add .')
message = "Site updated at #{Time.now.utc}"
run("git commit -m #{message.inspect}")
run("git push --force --quiet \"https://${GH_TOKEN}@github.com/#{GITHUB_REPONAME}\" master:master > /dev/null 2>&1", q: true)
end
end
end