forked from co-cddo/api-catalogue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
29 lines (24 loc) · 787 Bytes
/
Rakefile
File metadata and controls
29 lines (24 loc) · 787 Bytes
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
desc "Build middleman site"
task :build do
sh "bundle exec middleman build --clean --bail"
end
desc "Publish built site to Github pages"
task :publish do
require "tmpdir"
rev = `git rev-parse --short HEAD`.chomp
publish_dir = ENV.fetch("CLONED_GH_PAGES_DIR") do
tmp_dir = Dir.mktmpdir("publish-api-catalogue")
repo_url = `git config --get remote.origin.url`.chomp
sh("git clone --single-branch --branch gh-pages #{repo_url} #{tmp_dir}")
tmp_dir
end
sh("rsync -a --delete --exclude .git build/api-catalogue/ #{publish_dir}")
sh("git -C #{publish_dir} add --all")
sh("git -C #{publish_dir} commit -m 'Publish #{rev}'") do |ok, _|
if ok
sh("git -C #{publish_dir} push")
else
puts "Nothing to commit, skipping push"
end
end
end