Last active
August 29, 2015 14:26
-
-
Save thbar/3f5a4611f64084709fea to your computer and use it in GitHub Desktop.
The script to deploy the jekyll-based WiseCash Knowledge Base as part of my regular app deploy (or standalone)
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
namespace :help do | |
# a task to fetch our jekyll knowledge-base from github and deploy it here | |
task :deploy, [:clone_path] => :environment do |t, args| | |
logger = Logger.new(STDOUT) | |
# using https version so a clone does not require any auth | |
clone_url = "https://github.com/wisecash/wisecash-support.git" | |
# this is the nginx folder where help will be served from | |
destination = Rails.root.join('public/help') | |
# extra config (typekit id) | |
# see template here https://github.com/wisecash/wisecash-support/blob/master/_private_config.yml.sample | |
# the goal is to avoid leaving my own typekit ids (or other third party ids, such as drip) | |
# in the public repo | |
extra_config = Rails.root.join('config/kb-extra-config.yml') | |
# initially I wanted only a bundler cache but this raised issues | |
# so I'm creating a copy of the repo, and using the default bundler setup | |
clone_path = args[:clone_path] | |
fail "Missing clone path" if clone_path.blank? | |
# pull or update the knowledge-base git clone | |
if File.exists?(clone_path) | |
Dir.chdir(clone_path) do | |
logger.info "Cloning #{clone_url}" | |
system! "git fetch origin" | |
system! "git reset --hard origin/master" | |
end | |
else | |
logger.info "Updating clone of #{clone_url}" | |
system! "git clone #{clone_url} #{clone_path}" | |
end | |
# build the help site | |
Dir.chdir(clone_path) do | |
Bundler.with_clean_env do | |
logger.info "Running bundle install from #{Dir.pwd}" | |
system! "bundle install --deployment" | |
logger.info "Building jekyll" | |
system! "cd #{Dir.pwd} && bundle exec jekyll build --destination #{destination} -c _config.yml,#{extra_config}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment