|
|
|
@ -247,18 +247,21 @@ end
|
|
|
|
|
desc "deploy public directory to github pages"
|
|
|
|
|
multitask :push do
|
|
|
|
|
puts "## Deploying branch to Github Pages "
|
|
|
|
|
puts "## Pulling any updates from Github Pages "
|
|
|
|
|
cd "#{deploy_dir}" do
|
|
|
|
|
system "git pull"
|
|
|
|
|
end
|
|
|
|
|
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
|
|
|
|
|
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
|
|
|
|
|
puts "\n## copying #{public_dir} to #{deploy_dir}"
|
|
|
|
|
puts "\n## Copying #{public_dir} to #{deploy_dir}"
|
|
|
|
|
cp_r "#{public_dir}/.", deploy_dir
|
|
|
|
|
cd "#{deploy_dir}" do
|
|
|
|
|
system "git add ."
|
|
|
|
|
system "git add -u"
|
|
|
|
|
system "git add -A"
|
|
|
|
|
puts "\n## Commiting: Site updated at #{Time.now.utc}"
|
|
|
|
|
message = "Site updated at #{Time.now.utc}"
|
|
|
|
|
system "git commit -m \"#{message}\""
|
|
|
|
|
puts "\n## Pushing generated #{deploy_dir} website"
|
|
|
|
|
system "git push origin #{deploy_branch} --force"
|
|
|
|
|
system "git push origin #{deploy_branch}"
|
|
|
|
|
puts "\n## Github Pages deploy complete"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -304,10 +307,16 @@ task :setup_github_pages, :repo do |t, args|
|
|
|
|
|
repo_url = args.repo
|
|
|
|
|
else
|
|
|
|
|
puts "Enter the read/write url for your repository"
|
|
|
|
|
puts "(For example, 'git@github.com:your_username/your_username.github.io)"
|
|
|
|
|
puts "(For example, 'git@github.com:your_username/your_username.github.io.git)"
|
|
|
|
|
puts " or 'https://github.com/your_username/your_username.github.io')"
|
|
|
|
|
repo_url = get_stdin("Repository url: ")
|
|
|
|
|
end
|
|
|
|
|
user = repo_url.match(/:([^\/]+)/)[1]
|
|
|
|
|
protocol = (repo_url.match(/(^git)@/).nil?) ? 'https' : 'git'
|
|
|
|
|
if protocol == 'git'
|
|
|
|
|
user = repo_url.match(/:([^\/]+)/)[1]
|
|
|
|
|
else
|
|
|
|
|
user = repo_url.match(/github\.com\/([^\/]+)/)[1]
|
|
|
|
|
end
|
|
|
|
|
branch = (repo_url.match(/\/[\w-]+\.github\.(?:io|com)/).nil?) ? 'gh-pages' : 'master'
|
|
|
|
|
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
|
|
|
|
|
unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
|
|
|
|
@ -328,10 +337,8 @@ task :setup_github_pages, :repo do |t, args|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
url = "http://#{user}.github.io"
|
|
|
|
|
url += "/#{project}" unless project == ''
|
|
|
|
|
jekyll_config = IO.read('_config.yml')
|
|
|
|
|
jekyll_config.sub!(/^url:.*$/, "url: #{url}")
|
|
|
|
|
jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user, project)}")
|
|
|
|
|
File.open('_config.yml', 'w') do |f|
|
|
|
|
|
f.write jekyll_config
|
|
|
|
|
end
|
|
|
|
@ -351,7 +358,7 @@ task :setup_github_pages, :repo do |t, args|
|
|
|
|
|
f.write rakefile
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
puts "\n---\n## Now you can deploy to #{url} with `rake deploy` ##"
|
|
|
|
|
puts "\n---\n## Now you can deploy to #{repo_url} with `rake deploy` ##"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ok_failed(condition)
|
|
|
|
@ -376,6 +383,16 @@ def ask(message, valid_options)
|
|
|
|
|
answer
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def blog_url(user, project)
|
|
|
|
|
url = if File.exists?('source/CNAME')
|
|
|
|
|
"http://#{IO.read('source/CNAME').strip}"
|
|
|
|
|
else
|
|
|
|
|
"http://#{user}.github.io"
|
|
|
|
|
end
|
|
|
|
|
url += "/#{project}" unless project == ''
|
|
|
|
|
url
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
desc "list tasks"
|
|
|
|
|
task :list do
|
|
|
|
|
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
|
|
|
|
|