-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
91 lines (71 loc) · 2 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
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
require 'cgi'
require 'rake/clean'
CLEAN.include 'build', 'dist'
CLOBBER.include 'bower_components', 'node_modules', '.sass-cache'
task default: :build
desc 'Install all the dependencies required to build and deploy the site.'
task :deps do
bundle :install
npm :install
end
desc 'Update all the dependencies to the newest versions.'
task :update do
bundle :update
npm :update
bower :update
end
desc 'Build the web site and output the contents in the build/ folder.'
task :build do
middleman :build
end
desc 'Launch an interactive console with Middleman loaded.'
task :console do
middleman :console
end
desc 'Serve up the site locally, for development.'
task :serve do
sh 'foreman start'
end
desc 'Deploy the site to S3. Assumes you have AWS credentials in your environment. Assumes you have already run :build.'
task :deploy do
middleman :sync
rollbar
Rake::Task['ping'].invoke
end
task :ping do
domain = File.basename File.dirname(__FILE__)
sitemap = "https://#{domain}/sitemap.xml"
[
'http://www.google.com/webmasters/tools/ping?sitemap=',
'http://www.bing.com/ping?sitemap='
].each do |base_url|
url = base_url + CGI.escape(sitemap)
sh "curl '#{url}'"
end
end
# Helper methods to run external tasks.
def run(command, *args)
sh "#{command} #{args.join(' ')}"
end
def bundle(command, *args)
run :bundle, command, *args
end
def middleman(command, *args)
args << '--verbose' if verbose == true
bundle :exec, :middleman, command, *args
end
def npm(command, *args)
run :npm, command, *args
end
def bower(command, *args)
run 'node_modules/bower/bin/bower', command, *args
end
def rollbar
environment = 'production'
rollbar_token = ENV['ROLLBAR_TOKEN']
user = ENV['USER']
revision = ENV['TRAVIS_COMMIT'] || `git log -n 1 --pretty = format:"%H"`.chomp
if rollbar_token
sh "curl https://api.rollbar.com/api/1/deploy/ -F access_token=#{rollbar_token} -F environment=#{environment} -F revision=#{revision} -F local_username=#{user}"
end
end