2016-08-10 18:57:19 +02:00
|
|
|
require "rubygems"
|
|
|
|
require "tmpdir"
|
|
|
|
|
|
|
|
require "bundler/setup"
|
|
|
|
require "jekyll"
|
|
|
|
|
2016-08-11 11:44:18 +02:00
|
|
|
# Usage:
|
|
|
|
# rake site:publish -> testing: http://misp.github.io/misp-website
|
|
|
|
# rake publish -> prod: http://www.misp-project.org/ or http://misp.github.io
|
2016-08-10 18:57:19 +02:00
|
|
|
|
2016-08-11 11:40:36 +02:00
|
|
|
# Testing website
|
|
|
|
GITHUB_TESTING = "MISP/misp-website"
|
|
|
|
# Testing website
|
|
|
|
GITHUB_PROD = "MISP/misp.github.io"
|
2016-08-10 18:57:19 +02:00
|
|
|
|
2016-08-11 11:40:36 +02:00
|
|
|
desc "Generate blog files"
|
|
|
|
task :generate do
|
|
|
|
Jekyll::Site.new(Jekyll.configuration({
|
|
|
|
"source" => ".",
|
|
|
|
"destination" => "_site"
|
|
|
|
})).process
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
desc "Generate and publish blog to gh-pages"
|
|
|
|
task :publish => [:generate] do
|
|
|
|
Dir.mktmpdir do |tmp|
|
|
|
|
cp_r "_site/.", tmp
|
|
|
|
|
|
|
|
pwd = Dir.pwd
|
|
|
|
Dir.chdir tmp
|
|
|
|
|
|
|
|
system "git init"
|
|
|
|
system "git add ."
|
|
|
|
message = "Site updated at #{Time.now.utc}"
|
|
|
|
system "git commit -m #{message.inspect}"
|
|
|
|
system "git remote add origin git@github.com:#{GITHUB_PROD}.git"
|
|
|
|
system "git push origin master --force"
|
|
|
|
|
|
|
|
Dir.chdir pwd
|
|
|
|
end
|
|
|
|
end
|
2016-08-10 18:57:19 +02:00
|
|
|
|
|
|
|
namespace :site do
|
|
|
|
desc "Generate blog files"
|
|
|
|
task :generate do
|
|
|
|
Jekyll::Site.new(Jekyll.configuration({
|
|
|
|
"source" => ".",
|
|
|
|
"destination" => "_site"
|
|
|
|
})).process
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
desc "Generate and publish blog to gh-pages"
|
|
|
|
task :publish => [:generate] do
|
|
|
|
Dir.mktmpdir do |tmp|
|
|
|
|
cp_r "_site/.", tmp
|
|
|
|
|
|
|
|
pwd = Dir.pwd
|
|
|
|
Dir.chdir tmp
|
|
|
|
|
|
|
|
system "git init"
|
|
|
|
system "git add ."
|
|
|
|
message = "Site updated at #{Time.now.utc}"
|
|
|
|
system "git commit -m #{message.inspect}"
|
2016-08-11 11:40:36 +02:00
|
|
|
system "git remote add origin git@github.com:#{GITHUB_TESTING}.git"
|
2016-08-10 18:57:19 +02:00
|
|
|
system "git push origin master:refs/heads/gh-pages --force"
|
|
|
|
|
|
|
|
Dir.chdir pwd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|