-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
86 lines (66 loc) · 1.9 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
require 'html-proofer'
$sourceDir = "./source"
$outputDir = "./_site"
$testOpts = {
allow_hash_href: true,
assume_extension: true
}
hostname = ENV['SITE_HOSTNAME']
region = ENV['SITE_REGION']
task :default => ["serve:development"]
desc "cleans the output directory"
task :clean do
sh "jekyll clean"
end
namespace :deploy do
desc "upload to S3"
task :s3upload => [] do
bucket = `aws s3api list-buckets --query "Buckets[?contains(Name, '#{hostname}')] | [0].Name" | jq -r '.'`
p "Uploading to #{bucket} in #{region}"
htmls = File.join("**", "*.html")
# Remove extension from HTML files
Dir.glob(htmls, base: "_site") do |filename|
# Skip index.html
next if filename == "index.html"
filename_noext = filename.sub('.html', '')
p "Will move #{filename} to #{filename_noext}"
FileUtils.mv(filename, filename_noext)
end
p "Will upload non-HTML files"
sh %{
aws s3 sync _site/ s3://#{bucket} --region #{region} --delete \
--size-only --exclude "*" --include "*.*"
}
p "Will upload HTML files"
sh %{
aws s3 sync _site/ s3://#{bucket} --region #{region} --delete \
--content-type "text/html; charset=utf-8" --exclude "*.*"
}
end
end
namespace :build do
desc "build development site"
task :development => [:clean] do
sh "jekyll build --drafts"
end
desc "build production site"
task :production => [:clean] do
sh "JEKYLL_ENV=production jekyll build --config=_config.yml"
end
end
namespace :serve do
desc "serve development site"
task :development => [:clean] do
sh "jekyll serve --drafts"
end
desc "serve production site"
task :production => [:clean] do
sh "JEKYLL_ENV=production jekyll serve --config=_config.yml"
end
end
namespace :test do
desc "test production build"
task :production => ["build:production"] do
HTMLProofer.check_directory($outputDir, $testOpts).run
end
end