-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile.rb
41 lines (31 loc) · 800 Bytes
/
Rakefile.rb
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
Dir.chdir File.dirname __FILE__
WWW_DIR = ENV['WWW_DIR'] || '/var/www/default'
SITE_DIR = File.basename Dir.pwd
DEST_DIR = File.join WWW_DIR, SITE_DIR
task :default => :deploy
desc 'Clean previous site builds'
task :clean do
# Clean local files
rm_rf '_site'
# Clean deployed files
rm_rf DEST_DIR
rm_rf File.join WWW_DIR, 'lib'
end
desc 'Build Jekyll site'
task :build do
# Create a local config file
File.open '_local.yml', 'w' do |f|
f.write "baseurl: /#{SITE_DIR}\n"
end
# Build the site
sh 'jekyll', 'build', '--config', '_config.yml,_local.yml'
# Remove local config file
rm_f '_local.yml'
end
desc 'Deploy site locally'
task :deploy => [:clean, :build] do
# Move the site to deployment
mv '_site', DEST_DIR
# Move libraries
cp_r 'lib', WWW_DIR
end