forked from AlexanderTar/LASwift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
38 lines (32 loc) · 1.18 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
desc 'Generate docs using jazzy and publish to GitHub Pages.'
task :publish_docs do
# if this is a pull request, do a simple build of the site and stop
if ENV['TRAVIS_PULL_REQUEST'].to_s.to_i > 0
puts 'Pull request detected. No documentation needed'
next
end
repo_dir = 'LASwift-docs'
repo_url = 'https://github.com/AlexanderTar/LASwift-docs.git'
jazzy_path = Rake.application.original_dir + '/docs'
jazzy_path.strip!
last_commit_message = `git log -1 --pretty=%B`
last_commit_message.strip!
system "[ -d '#{repo_dir}' ] && rm -rf '#{repo_dir}'"
system "git clone #{repo_url} #{repo_dir} --depth 1"
Dir.chdir(repo_dir)
system "git config user.name '#{ENV['GIT_NAME']}'"
system "git config user.email '#{ENV['GIT_EMAIL']}'"
system 'git config credential.helper "store --file=.git/credentials"'
system 'rm -rf doc'
system "cp -r '#{jazzy_path}' ."
system 'git add . --all'
system "git commit -m 'update-docs: #{last_commit_message}'"
begin
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GIT_TOKEN']}:[email protected]")
end
system 'git push origin master'
ensure
File.delete '.git/credentials'
end
end