From 4efb29394fcb99a77eea708e51c7dbc04aca0f94 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 22 Sep 2011 04:41:40 -0500 Subject: improved github configuration raketask --- Rakefile | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 1b5d993a..05749208 100644 --- a/Rakefile +++ b/Rakefile @@ -274,25 +274,54 @@ task :set_root_dir, :dir do |t, args| end end -desc "Setup _deploy folder and deploy branch" -task :config_deploy, :branch do |t, args| - puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch - puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment" +desc "Set up _deploy folder and deploy branch for Github Pages deployment" +task :setup_github do + repo_url = get_stdin("Enter the read/write url for your repository: ") + 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 - system "git symbolic-ref HEAD refs/heads/#{args.branch}" - system "rm .git/index" - system "git clean -fdx" + system "git init" system "echo 'My Octopress Page is coming soon …' > index.html" system "git add ." 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.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") File.open(__FILE__, 'w') do |f| f.write rakefile 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 def ok_failed(condition) -- cgit v1.2.1 From fcb730b5bf6c76f8f36512461181df4f537cc16a Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 22 Sep 2011 04:43:09 -0500 Subject: Restored copying public into _deploy. fixes #169 --- Rakefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 05749208..4fcafbd5 100644 --- a/Rakefile +++ b/Rakefile @@ -227,6 +227,7 @@ multitask :push do (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } Rake::Task[:copydot].invoke(public_dir, deploy_dir) puts "\n## copying #{public_dir} to #{deploy_dir}" + system "cp -R #{public_dir}/* #{deploy_dir}" cd "#{deploy_dir}" do system "git add ." system "git add -u" -- cgit v1.2.1 From 4d491494049dcea091cee8b06943ac8a7d3ad34b Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 22 Sep 2011 04:45:44 -0500 Subject: renamed github pages configuration task --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 4fcafbd5..df19b9d4 100644 --- a/Rakefile +++ b/Rakefile @@ -276,7 +276,7 @@ task :set_root_dir, :dir do |t, args| end desc "Set up _deploy folder and deploy branch for Github Pages deployment" -task :setup_github do +task :setup_github_pages do repo_url = get_stdin("Enter the read/write url for your repository: ") user = repo_url.match(/:([^\/]+)/)[1] branch = (repo_url.match(/\/\w+.github.com/).nil?) ? 'gh-pages' : 'master' -- cgit v1.2.1 From aa1abd0827e764da84b3c6c8e96bbd89d1f59d34 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 22 Sep 2011 16:16:54 -0500 Subject: now Github pages :push task forces --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index df19b9d4..eb91e37f 100644 --- a/Rakefile +++ b/Rakefile @@ -235,7 +235,7 @@ multitask :push do 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}" + system "git push origin #{deploy_branch} --force" puts "\n## Github Pages deploy complete" end end -- cgit v1.2.1 From a4177e1471a649c51ddb6def3aa6be0352056d4a Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 26 Sep 2011 00:13:42 +0300 Subject: Changed it so the ssh port is configurable as well. (As I ran into the same issue already described at https://github.com/imathis/octopress/issues/30 ) --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index eb91e37f..a74d51b1 100644 --- a/Rakefile +++ b/Rakefile @@ -5,6 +5,7 @@ require "stringex" ## -- Rsync Deploy config -- ## # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file ssh_user = "user@domain.com" +ssh_port = "22" document_root = "~/website.com/" deploy_default = "rsync" @@ -218,7 +219,7 @@ end desc "Deploy website via rsync" task :rsync do puts "## Deploying website via Rsync" - ok_failed system("rsync -avz --delete #{public_dir}/ #{ssh_user}:#{document_root}") + ok_failed system("rsync -avze 'ssh -p {ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}") end desc "deploy public directory to github pages" -- cgit v1.2.1 From af1f2af48f4e6cc49b9c619654e5038f2353955f Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 26 Sep 2011 00:16:15 +0300 Subject: Typo. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index a74d51b1..20c618e0 100644 --- a/Rakefile +++ b/Rakefile @@ -219,7 +219,7 @@ end desc "Deploy website via rsync" task :rsync do puts "## Deploying website via Rsync" - ok_failed system("rsync -avze 'ssh -p {ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}") + ok_failed system("rsync -avze 'ssh -p #{ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}") end desc "deploy public directory to github pages" -- cgit v1.2.1