-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
57 lines (47 loc) · 1.16 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
require "tmpdir"
GITHUB_REPONAME = "idevqa/interval"
GITHUB_REPO_BRANCH = "gh-pages"
DEST = "public/."
IMG_DEST = "static/."
task default: %w[publish]
desc "Generate book static files by Hugo"
task :gen do
system "hugo"
end
desc "Update content"
task :u do
Dir.chdir("./content") do
system "git pull origin master"
end
end
desc "Run Hugo server to test"
task :s do
system "hugo server --minify --theme book"
end
desc "Make dev env ready"
task :ready do
sys = ENV['sys']
if sys == "ubuntu"
system "sudo apt-get install hugo"
elsif sys == "macos"
system "brew install hugo"
end
system "bundle install"
system "git submodule update --init"
end
desc "Generate and publish book to my Repo"
task :publish => [:u, :gen] do
Dir.mktmpdir do |tmp|
cp_r DEST, tmp
pwd = Dir.pwd
Dir.chdir tmp
system "git init"
system "git checkout --orphan #{GITHUB_REPO_BRANCH}"
system "git add ."
msg = "#{Time.now.utc}"
system "git commit -am '#{msg}: Published'"
system "git remote add origin [email protected]:#{GITHUB_REPONAME}.git"
system "git push origin #{GITHUB_REPO_BRANCH} --force"
Dir.chdir pwd
end
end