-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
node("${env.NODE}") { | ||
currentBuild.result = "SUCCESS" | ||
|
||
try { | ||
stage('Clean up') { | ||
deleteDir() | ||
} | ||
|
||
stage('Checkout') { | ||
checkout scm | ||
} | ||
|
||
stage('D/L dependencies') { | ||
sh 'gem install bundler' | ||
sh 'bundle' | ||
} | ||
|
||
stage('Test') { | ||
sh 'rake test:production' | ||
} | ||
|
||
stage('Build production') { | ||
sh 'rake build:production' | ||
} | ||
|
||
stage('Deploy') { | ||
def files = findFiles(glob: '_site/**/*') | ||
files.each { | ||
def file = it | ||
def dst = file.path.replace('_site/', '') | ||
println "file: ${file}" | ||
println "name: ${file.name}" | ||
println "path: ${file.path}" | ||
println "dst: ${dst}" | ||
|
||
withAWS(region:"${env.REGION}",credentials:"${env.CREDENTIAL}") { | ||
s3Upload( | ||
bucket: "${env.HOST}", | ||
file: "${file.path}", | ||
path: "${dst}", | ||
) | ||
} | ||
} | ||
} | ||
|
||
stage('Invalidate Cloudfront') { | ||
withAWS(region:"${env.REGION}",credentials:"${env.CREDENTIAL}") { | ||
cfInvalidate(distribution: "${env.CF_DIST_ID}", paths: ['/*']) | ||
} | ||
} | ||
} catch (err) { | ||
currentBuild.result = 'FAILURE' | ||
throw err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
require 'html-proofer' | ||
|
||
$sourceDir = "./source" | ||
$outputDir = "./output" | ||
$testOpts = { | ||
# Ignore errors "linking to internal hash # that does not exist" | ||
:url_ignore => ["#"], | ||
# Allow empty alt tags (e.g. alt="") as these represent presentational images | ||
:empty_alt_ignore => 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 |