forked from y7kim/agency-jekyll-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
41 lines (36 loc) · 1.51 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
require "tmpdir"
source_branch = "source"
production_branch = "gh-pages"
desc "Deploy _site/ to #{production_branch} branch"
task :deploy do
Dir.mktmpdir do |tmp|
puts "\n## Moving #{source_branch} branch _site contents to tmp folder"
status = system("mv _site/* #{tmp}")
puts status ? "Success" : "Failed"
puts "\n## Switching to #{production_branch} branch"
status = system("git checkout #{production_branch}")
puts status ? "Success" : "Failed"
puts "\n## Pulling most recent #{production_branch} branch from remote"
status = system("git pull")
puts status ? "Success" : "Failed"
puts "\n## Removing #{production_branch} branch contents"
status = system("rm -rf *")
puts status ? "Success" : "Failed"
puts "\n## Moving contents in tmp folder to #{production_branch} branch"
status = system("mv #{tmp}/* .")
puts status ? "Success" : "Failed"
end
puts "\n## Adding #{production_branch} branch changes"
status = system("git add -A")
puts status ? "Success" : "Failed"
puts "\n## Committing production site at #{Time.now.utc}"
message = "Build production site at #{Time.now.utc}"
status = system("git commit -m \"#{message}\"")
puts status ? "Success" : "Failed"
puts "\n## Pushing commits to remote #{production_branch}"
status = system("git push origin #{production_branch}")
puts status ? "Success" : "Failed"
puts "\n## Switching back to #{source_branch} branch"
status = system("git checkout #{source_branch}")
puts status ? "Success" : "Failed"
end