-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
33 lines (26 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
require 'rubygems'
desc 'Generate site from Travis CI and publish site to GitHub Pages'
task :travis do
if ENV['TRAVIS_PULL_REQUEST'].to_s.to_i > 0
puts 'Pull request detected. Executing build only.'
system 'jekyll build && bundle exec awestruct -P production -g'
next
end
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:')
deploy_branch = 'master'
if repo.match(/github\.com\.git$/)
deploy_branch = 'master'
end
system "git remote set-url --push origin #{repo}"
system "git remote set-branches --add origin #{deploy_branch}"
system 'git fetch -q'
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"'
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:@github.com")
end
system "git branch #{deploy_branch} origin/#{deploy_branch}"
system 'bundle exec awestruct -P production -g --deploy'
File.delete '.git/credentials'
end