forked from aptible/www.aptible.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
69 lines (56 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
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'rspec/core/rake_task'
require 'yaml'
require_relative 'helpers/contentful_helpers'
def system!(cmd)
success = !!system(cmd)
exitstatus = $CHILD_STATUS.exitstatus
raise "Command failed (exit #{exitstatus}): #{cmd}" unless success
end
desc 'Tag current HEAD and push to release branch'
task :deploy, [:bucket] => [:redirect, 'contentful:pull'] do |_t, args|
raise 'No bucket specified' unless args[:bucket]
# Build site
system!('bundle exec middleman build')
# Upload to S3
opts = '--acl public-read ' \
'--cache-control max-age=300,s-maxage=300'
# http://makandracards.com/makandra/15649
Bundler.with_clean_env do
system!("aws s3 sync #{opts} build s3://#{args[:bucket]}")
end
end
task :redirect, [:bucket] do |_t, args|
raise 'No bucket specified' unless args[:bucket]
Bundler.with_clean_env do
ENV['S3_BUCKET'] = args[:bucket]
system!('bundle exec middleman s3_redirect')
end
end
namespace :deploy do
desc 'Build and deploy site to www.aptible-staging.com'
task :staging do
ENV['BASE_URL'] = 'https://www.aptible-staging.com'
ENV['BASE_DOC_URL'] = 'https://www.aptible-staging.com'
ENV['SEGMENTIO_WRITEKEY'] = 'K24Jna8XS0PRiQiISYZ563qC3SfHF241'
ENV['CONTENTFUL_TOKEN'] = 'b66d39f51cfcc747ca3af1b7731bd00c' \
'f877b659d69514845ba837ddae473605'
ENV['CONTENTFUL_PREVIEW_MODE'] = 'true'
Rake::Task[:deploy].invoke('www.aptible-staging.com')
end
desc 'Build and deploy site to www.aptible.com'
task :production do
ENV['BASE_URL'] = 'https://www.aptible.com'
ENV['BASE_DOC_URL'] = 'https://www.aptible.com'
ENV['SEGMENTIO_WRITEKEY'] = 'rkt88i7k3w'
Rake::Task[:deploy].invoke('www.aptible.com')
end
end
namespace :contentful do
desc 'Populate Markdown files from Contentful data'
task :pull do
ContentfulHelpers.populate!
end
end
RSpec::Core::RakeTask.new(:spec)
require 'aptible/tasks'
Aptible::Tasks.load_tasks