-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
35 lines (29 loc) · 869 Bytes
/
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
require "rubygems"
require "tmpdir"
require "bundler/setup"
require "jekyll"
# Your github username with repository name
GITHUB_REPONAME = "ricardopacheco/ricardopacheco.github.io"
desc "Generate static site"
task :generate do
Jekyll::Site.new(Jekyll.configuration({
"source" => ".",
"destination" => "_site"
})).process
end
desc "Generate static site and publish on github"
task publish: %I[generate] do
Dir.mktmpdir do |tmp|
cp_r "_site/.", tmp
pwd = Dir.pwd
Dir.chdir tmp
File.open(".nojekyll", "wb") { |f| f.puts("Site generated locally.") }
system "git init"
system "git add ."
message = "Page updated on #{Time.now.utc}"
system "git commit -m #{message.inspect}"
system "git remote add origin [email protected]:#{GITHUB_REPONAME}.git"
system "git push --force origin main"
Dir.chdir pwd
end
end