-
Notifications
You must be signed in to change notification settings - Fork 15
/
Rakefile
56 lines (48 loc) · 1.92 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
require "tmpdir"
source_branch = "source"
production_branch = "master"
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"
if not status then exit end
puts "\n## Switching to #{production_branch} branch"
status = system("git checkout #{production_branch}")
puts status ? "Success" : "Failed"
if not status then exit end
puts "\n## Pulling most recent #{production_branch} branch from remote"
status = system("git pull")
puts status ? "Success" : "Failed"
if not status then exit end
puts "\n## Removing #{production_branch} branch contents"
status = system("rm -rf *")
puts status ? "Success" : "Failed"
if not status then exit end
puts "\n## Moving contents in tmp folder to #{production_branch} branch"
status = system("mv #{tmp}/* .")
puts status ? "Success" : "Failed"
if not status then exit end
end
puts "\n## Adding #{production_branch} branch changes"
status = system("git add -A")
puts status ? "Success" : "Failed"
if not status then exit end
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"
if not status then exit end
puts "\n## Pushing #{production_branch} branch commits to remote"
status = system("git push origin #{production_branch}")
puts status ? "Success" : "Failed"
if not status then exit end
puts "\n## Switching back to #{source_branch} branch"
status = system("git checkout #{source_branch}")
puts status ? "Success" : "Failed"
if not status then exit end
puts "\n## Pushing #{source_branch} branch commits to remote"
status = system("git push")
puts status ? "Success" : "Failed"
end