forked from algorithmiaio/api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
48 lines (38 loc) · 1.02 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
require "rubygems"
require "tmpdir"
require "bundler/setup"
task :default => [:build]
desc "Build the static site"
task :build do
puts "Building project"
system "rm -rf build/*"
try "middleman build"
puts "Build complete 🛠"
end
GITHUB_REPONAME = "algorithmiaio/api-docs"
desc "Generate and publish blog to gh-pages"
namespace :shippable do
task :publish do
Rake::Task["build"].invoke
Dir.mktmpdir do |tmp|
cp_r "build/.", tmp
pwd = Dir.pwd
Dir.chdir tmp
system "git init"
system "git add ."
message = "Site updated at #{Time.now.utc}"
system "git commit -m #{message.inspect}"
system "git remote add origin [email protected]:#{GITHUB_REPONAME}.git"
system "git push origin master:refs/heads/gh-pages --force"
system "echo Site updated! 💃"
Dir.chdir pwd
end
end
end
## Helper so we fail as soon as a command fails.
def try(command)
system command
if $? != 0 then
raise "Command: `#{command}` exited with code #{$?.exitstatus}"
end
end