-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
62 lines (48 loc) · 1.29 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
require "fileutils"
require "git"
require "logger"
REPO_DIR = "tmp/kitchen-docs"
DOC_DIR = "source/docs"
LAST_COMMIT_MSG_FILE = "tmp/last_commit_message"
$stdout.sync = true
logger = Logger.new(STDOUT)
task :default => [:update_docs]
task :publish => [:pull, :update_docs, :commit, :push]
task :pull do
git = Git.open(Dir.pwd, :log => logger)
git.pull
end
task :update_docs do
puts "Cleaning up #{REPO_DIR}"
FileUtils.rm_rf(REPO_DIR)
puts "Cleaning up #{DOC_DIR}"
FileUtils.rm_rf(DOC_DIR)
puts "Cloning Kitchen Docs repository ..."
git = Git.clone("https://github.com/test-kitchen/kitchen-docs.git", REPO_DIR)
File.open(LAST_COMMIT_MSG_FILE, "wb") do |file|
file.write(git.log.first.message)
end
puts "Copying Kitchen Docs ..."
FileUtils.cp_r(File.join(REPO_DIR, DOC_DIR), DOC_DIR)
puts "Cleaning up #{REPO_DIR}"
FileUtils.rm_rf(REPO_DIR)
end
task :commit do
message = "automated commit"
if File.exists?(LAST_COMMIT_MSG_FILE)
message = File.open(LAST_COMMIT_MSG_FILE, "r").read
end
git = Git.open(Dir.pwd, :log => logger)
git.add
git.commit(message)
end
task :push do
git = Git.open(Dir.pwd, :log => logger)
git.push
git.push(git.remote("heroku"))
end
namespace :assets do
task :precompile do
sh "middleman build --clean --verbose"
end
end