forked from alexandru/alexn.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
52 lines (39 loc) · 1.35 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
require 'bundler/setup'
require 'yaml'
include Rake::DSL
CONFIG = YAML::load(File.open('./_config.yml'))
task :compile do
sh "jekyll"
end
namespace :deploy do
desc "Deploys assets to GAE"
task :gae do
Dir.entries('./lib/gae/').find_all{|x| x =~ /app\d+.ya?ml/}.each do |app|
config = YAML::load(File.read "./lib/gae/#{app}")
puts
puts "Deploying CDN #{config['application']}.appspot.com ..."
puts
rm_rf "/tmp/gaecdn"
mkdir "/tmp/gaecdn"
sh "cp -rf ./#{CONFIG['destination']}/assets /tmp/gaecdn/"
sh "cp -rf ./lib/gae/* /tmp/gaecdn/"
sh "cp ./lib/gae/#{app} /tmp/gaecdn/app.yaml"
sh "rm /tmp/gaecdn/#{app}"
Dir.chdir("/tmp/gaecdn") do
sh "appcfg.py update ."
end
end
end
desc "Deploy assets to CloudFront/S3"
task :aws do
# sets a 1 year expiry header this also means that resources can't
# be updated without invalidating them first in CloudFront, which is
# a PITA, so this is good for images, but not CSS
sh 's3cmd sync ./build/assets/ s3://bionicspirit/assets/ --acl-public --add-header "Cache-Control: public, max-age=22896000"'
end
desc "Deploy to my server (with RSync)"
task :ec2 do
sh "rsync --exclude=\".*\" -rcv ./ bionicspirit.com:/var/www/bionicspirit.com/"
end
end
task :default => [:compile, 'deploy:aws', 'deploy:ec2']