mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-25 00:48:53 -05:00
improved github configuration raketask
This commit is contained in:
parent
92ff4a9c67
commit
4efb29394f
47
Rakefile
47
Rakefile
@ -274,25 +274,54 @@ task :set_root_dir, :dir do |t, args|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Setup _deploy folder and deploy branch"
|
desc "Set up _deploy folder and deploy branch for Github Pages deployment"
|
||||||
task :config_deploy, :branch do |t, args|
|
task :setup_github do
|
||||||
puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch
|
repo_url = get_stdin("Enter the read/write url for your repository: ")
|
||||||
puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
|
user = repo_url.match(/:([^\/]+)/)[1]
|
||||||
|
branch = (repo_url.match(/\/\w+.github.com/).nil?) ? 'gh-pages' : 'master'
|
||||||
|
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
|
||||||
|
unless `git remote -v`.match(/origin.+?octopress.git/).nil?
|
||||||
|
# If octopress is still the origin remote (from cloning) rename it to octopress
|
||||||
|
system "git remote rename origin octopress"
|
||||||
|
if branch == 'master'
|
||||||
|
# If this is a user/organization pages repository, add the correct origin remote
|
||||||
|
# and checkout the source branch for committing changes to the blog source.
|
||||||
|
system "git remote add origin #{repo_url}"
|
||||||
|
puts "Added remote #{repo_url} as origin"
|
||||||
|
system "git config branch.master.remote origin"
|
||||||
|
puts "Set origin as default remote"
|
||||||
|
system "git branch -m master source"
|
||||||
|
puts "Master branch renamed to 'source' for committing your blog source files"
|
||||||
|
else
|
||||||
|
unless !public_dir.match("#{project}").nil?
|
||||||
|
system "rake set_root_dir[#{project}]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
url = "http://#{user}.github.com"
|
||||||
|
url += "/#{project}" unless project == ''
|
||||||
|
jekyll_config = IO.read('_config.yml')
|
||||||
|
jekyll_config.sub!(/^url:.*$/, "url: #{url}")
|
||||||
|
File.open('_config.yml', 'w') do |f|
|
||||||
|
f.write jekyll_config
|
||||||
|
end
|
||||||
|
rm_rf deploy_dir
|
||||||
|
mkdir deploy_dir
|
||||||
cd "#{deploy_dir}" do
|
cd "#{deploy_dir}" do
|
||||||
system "git symbolic-ref HEAD refs/heads/#{args.branch}"
|
system "git init"
|
||||||
system "rm .git/index"
|
|
||||||
system "git clean -fdx"
|
|
||||||
system "echo 'My Octopress Page is coming soon …' > index.html"
|
system "echo 'My Octopress Page is coming soon …' > index.html"
|
||||||
system "git add ."
|
system "git add ."
|
||||||
system "git commit -m \"Octopress init\""
|
system "git commit -m \"Octopress init\""
|
||||||
|
system "git branch -m gh-pages" unless branch == 'master'
|
||||||
|
system "git remote add origin #{repo_url}"
|
||||||
rakefile = IO.read(__FILE__)
|
rakefile = IO.read(__FILE__)
|
||||||
rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{args.branch}\\3")
|
rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{branch}\\3")
|
||||||
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
|
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
|
||||||
File.open(__FILE__, 'w') do |f|
|
File.open(__FILE__, 'w') do |f|
|
||||||
f.write rakefile
|
f.write rakefile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "## Deployment configured. Now you can deploy to the #{args.branch} branch with `rake deploy` ##"
|
puts "\n---\n## Now you can deploy to #{url} with `rake deploy` ##"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ok_failed(condition)
|
def ok_failed(condition)
|
||||||
|
Loading…
Reference in New Issue
Block a user