-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathRakefile
executable file
·79 lines (64 loc) · 2.07 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env rake
desc 'Initial setup'
task :bootstrap do
FileUtils.rm_rf '_gh-pages'
puts 'Cloning gh-pages branch...'
url = `git ls-remote --get-url origin`
puts `git clone #{url.strip} _gh-pages`
Dir.chdir('_gh-pages') do
puts `git checkout gh-pages`
end
puts 'Cloning submodules...'
puts `git submodule update --init --recursive`
puts 'Installing Bundle...'
puts `bundle install`
end
# Deprecated, but leaving shortcut in because I'm sure Orta, at least, has this
# in his muscle-memory.
task :init => :bootstrap
namespace :serve do
desc 'Runs a local server *with* draft posts and watches for changes'
task :drafts do
puts 'Starting the server locally on http://localhost:4000'
sh 'bundle exec jekyll serve --watch --drafts --port 4000'
end
desc 'Runs a local server *without* draft posts and watches for changes'
task :published do
puts 'Starting the server locally on http://localhost:4000'
sh 'bundle exec jekyll serve --watch --port 4000'
end
end
desc 'Runs a local server with draft posts and watches for changes'
task :serve => 'serve:drafts'
desc 'Deploy the site to the gh_pages branch and push'
task :deploy do
FileUtils.rm_rf '_gh-pages'
puts 'Cloning gh-pages branch...'
url = `git ls-remote --get-url origin`
puts `git clone #{url.strip} _gh-pages`
Dir.chdir('_gh-pages') do
puts `git checkout gh-pages`
end
Dir.chdir('_gh-pages') do
puts 'Pulling changes from server.'
puts `git reset --hard`
puts `git clean -xdf`
puts `git checkout gh-pages`
puts `git pull origin gh-pages`
end
puts 'Building site.'
puts `bundle exec jekyll build -d _gh-pages`
Dir.chdir('_gh-pages') do
puts 'Pulling changes from server.'
puts `git checkout gh-pages`
puts `git pull origin gh-pages`
puts 'Creating a commit for the deploy.'
puts `git ls-files --deleted -z | xargs -0 git rm;`
puts `git add .`
puts `git commit -m "Deploy"`
puts 'Pushing to github.'
puts `git push --quiet > /dev/null 2>&1`
end
end
desc 'Defaults to serve:drafts'
task :default => 'serve:drafts'