-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
60 lines (55 loc) · 1.78 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
#require 'middleman-gh-pages'
#ENV["BRANCH_NAME"] = 'master'
require 'rubygems'
desc 'Generate site from Travis CI and publish site to GitHub Pages'
task :travis 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. Executing build only.'
system 'bundle exec middleman build'
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 'ALIEN FROM MARS'"
system "git config user.email '#{ENV['COMMIT_AUTHOR_EMAIL']}'"
system 'git config credential.helper "store --file=.git/credentials"'
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:[email protected]")
end
puts 'gh-token'
puts ENV['GH_TOKEN']
system 'git pull origin source'
print 'building'
system 'bundle exec middleman build'
puts '$ mv build ../'
system 'mv build ../'
#puts 'commiting'
#system 'git commit -am "travis built"'
puts '$ pwd'
system 'pwd'
print 'listing branches'
system 'git branch'
print 'branching'
system "git branch #{deploy_branch} origin/#{deploy_branch}"
system 'git checkout master'
puts 'branch:'
system 'git branch'
puts '$ rm -rf *'
system 'rm -rf *'
puts '$ mv ../build/* .'
system 'mv ../build/* .'
puts '$ ls -a'
system 'ls -a'
puts '$ git add -A && git commit -am "add build"'
system 'git add -A && git commit -am "add build"'
puts '$ git push origin source'
system 'git push origin source'
File.delete '.git/credentials'
end