This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
/
Rakefile.rb
118 lines (101 loc) · 3.68 KB
/
Rakefile.rb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
##############
# Jekyll tasks
##############
# Usage: rake serve, rake serve:prod
task :serve => ["serve:dev"]
namespace :serve do
desc "Serve development Jekyll site locally"
task :dev do
puts "Starting up development Jekyll site server..."
system "bundle exec jekyll serve --no-watch --config _config.yml,_config.dev.yml"
end
desc "Serve production Jekyll site locally"
task :prod do
puts "Starting up production Jekyll site server..."
system "bundle exec jekyll serve --no-watch"
end
end
# Usage: rake build, rake build:dev, rake build:drafts
task :build => ["build:prod"]
namespace :build do
desc "Regenerate files for production"
task :prod do
puts "* Regenerating files for production..."
system "JEKYLL_ENV=production bundle exec jekyll build"
end
desc "Regenerate files for production (Windows systems)"
task :win do
puts "* Regenerating files for production..."
system "bundle exec jekyll build"
end
desc "Regenerate files for development"
task :dev do
puts "* Regenerating files for development..."
system "bundle exec jekyll build --config _config.yml,_config.dev.yml --profile"
end
desc "Regenerate files and drafts for development"
task :drafts do
puts "* Regenerating files and drafts for development..."
system "bundle exec jekyll build --config _config.yml,_config.dev.yml --profile --drafts"
end
end
####################
# Notification tasks
####################
# Usage: rake notify
task :notify => ["notify:pingomatic", "notify:google", "notify:bing"]
desc "Notify various services that the site has been updated"
namespace :notify do
desc "Notify Ping-O-Matic"
task :pingomatic do
begin
require 'xmlrpc/client'
puts "* Notifying Ping-O-Matic that the site has updated"
XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'mademistakes.com' , 'https://mademistakes.com', 'https://mademistakes.com/atom.xml')
rescue LoadError
puts "! Could not ping ping-o-matic, because XMLRPC::Client could not be found."
end
end
desc "Notify Google of updated sitemap"
task :google do
begin
require 'net/http'
require 'uri'
puts "* Notifying Google that the site has updated"
Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('https://mademistakes.com/sitemap.xml'))
rescue LoadError
puts "! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found."
end
end
desc "Notify Bing of updated sitemap"
task :bing do
begin
require 'net/http'
require 'uri'
puts '* Notifying Bing that the site has updated'
Net::HTTP.get('www.bing.com', '/webmaster/ping.aspx?siteMap=' + URI.escape('https://mademistakes.com/sitemap.xml'))
rescue LoadError
puts "! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found."
end
end
end
##################
# Deployment tasks
##################
# Usage: rake rsync
desc "rsync the contents of ./_site to the server"
task :rsync do
puts "* rsyncing the contents of ./_site to the server"
system "rsync --perms --recursive --verbose --compress --delete --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r _site/ new-mademistakes.com@s210904.gridserver.com:domains/mademistakes.com/html/"
end
# Usage: rake deploy, rake deploy:win
task :deploy => ["deploy:prod"]
namespace :deploy do
desc "Regenerate and rsync production files and notify services of the update"
task :prod => ["build", "rsync", "notify"] do
end
# Usage: rake deploy:win
desc "Regenerate and rsync production files and notify services of the update (Windows systems)"
task :win => ["build:win", "rsync", "notify"] do
end
end