Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Pages Deploy Plugin #39

Closed
balupton opened this issue Sep 20, 2011 · 31 comments
Closed

GitHub Pages Deploy Plugin #39

balupton opened this issue Sep 20, 2011 · 31 comments

Comments

@balupton
Copy link
Member

After a generate has finished, it should wipe the gh-pages branch, copy the contents of the original out directory into it, add the changes, commit them, and check back to the original branch.

@balupton
Copy link
Member Author

Continued here: #385

@deitch
Copy link

deitch commented Feb 10, 2013

I'll take the combination of @sergeylukin and my script and make it a plugin. Please send me link on how I write a plugin that extends the docpad command and I'll make it happen. I know how to do a generic plugin, not a docpad command extending one.

@sergeylukin
Copy link

Sounds like a good plan:) I think at least 1 config variable should be available: branch name. That's because Github use "gh-pages" branch for project repos and "master" branch for user/organization repos.

@balupton
Copy link
Member Author

Alright I've created https://github.com/docpad/docpad-plugin-ghpages and given you both push + pull access. It appears however that the consoleSetup event is not fired as it should have been. I'll look into this when I get some more time - feel free to look into it yourselves though.

@balupton
Copy link
Member Author

Okay it seems the issue is that the plugins are not loaded at the time that event is fired. Looking into it, it is due to the load:false here - https://github.com/bevry/docpad/blob/master/src/bin/docpad.coffee#L6 - changing that to load:true makes it work, however I'm sure there is real good reason why that is there. Should be looked into.

For now, just make that load:true so you can continue development on this plugin. Instructions on how you can work on the docpad core are inside the CONTRIBUTING.md file.

@deitch
Copy link

deitch commented Feb 10, 2013

Cool. I like how that works, looking at your template.

So everything that has to happen can boil down to:

  1. docpad generate
  2. cd to ./out
  3. git stuff
  4. clean up rm -rf .git
  5. cd back to ../

1 is covered via docpad.action 'generate', {env:opts.environment}. 2 & 5 are easy to cover with cwd. 4 is coverable with rimraf. The remaining question is the git stuff.

Two options:

  1. wrap the user's command-line git. Depends on the local install, but you know it will inherit all of the user's prefs (and ssh keys, etc.)
  2. use a native node git client

Preferences?

@deitch
Copy link

deitch commented Feb 10, 2013

Separately: if we have direct push/pull access on the repo, would you prefer a separate repo deitch/docpad-plugin-ghpages and I issue a pull request to it and then pull, or that I work directly against docpad/docpad-plugin-ghpages ?

@sergeylukin
Copy link

Regarding git stuff I was thinking about something like that:

var exec = require('child_process').exec,
     remote_repo = exec('git config remote.origin.url', function() {}),
     remote_branch = 'gh-pages',
     git_command = 'git init' +
                             ' && git add .' +
                             " && git commit -m 'build'" +
                             ' && git push ' + remote_repo + ' master:' + remote_branch + ' --force' +
                             '';
// Execute git commands
exec(git_command,
  function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
});

What do you think?

@deitch
Copy link

deitch commented Feb 10, 2013

Heh, I just finished writing something almost exactly like that! :-) Along with README.md, etc.

Except that getting the remote_repo that way doesn't work, since exec() returns the child_process, not the output of stdout.

Hold on, I will push the interim changes out to the repo that @balupton just gave us access to, we can both work from there.

@deitch
Copy link

deitch commented Feb 10, 2013

Huh! I try, but github isn't accepting my push.

In the repo page on the Web, I see the URLs show read+write access, and I have ssh, so I push easily to all my other repos, but this one, when I do, it says:

# git push origin master
Username:
Password:

Weird?

@balupton
Copy link
Member Author

Could be that you cloned the HTTPS rather the SSH address

@deitch
Copy link

deitch commented Feb 10, 2013

You're right, I did. But looking at the addresses, it shows R/W for both of them.

I'll change it anyways and try.

@deitch
Copy link

deitch commented Feb 10, 2013

Yeah, that did it. Strange how it didn't take it, though.

@deitch
Copy link

deitch commented Feb 10, 2013

BTW, what I pushed to the repo was barely reviewed, more like pseudo-coffee-code than code. Just trying to get it into the hands of the rest here.

@deitch
Copy link

deitch commented Feb 10, 2013

Something strange here. I modified my local install to load:true so that I get the modules. Fine.

When I do, I get an error

warning: An error occured: 
Error: Cannot find module '/...../node_modules/docpad-plugin-ghpages'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at PluginLoader.load (/Users/adeitcher/local/lib/node_modules/docpad/out/lib/plugin-loader.js:144:26)

But I know it is installed locally. I run npm ls and it is there??

@deitch
Copy link

deitch commented Feb 10, 2013

Never mind, my own mistake. Ignore.

@deitch
Copy link

deitch commented Feb 10, 2013

OK, question: you use

docpad.action 'generate'

How do I make it the equivalent of docpad generate --env static ? I tried

docpad.action 'generate', {env:opts.environment or 'static'}

But it didn't work, even though opts.environment was undefined.

@deitch
Copy link

deitch commented Feb 10, 2013

Hmm, even stranger. It seems to completely ignore the env option after the docpad instance is already created.

@deitch
Copy link

deitch commented Feb 10, 2013

Weird, but I got it. You need to set commander.env = 'static' for it to work.

Now I cannot get it any further without having load:false to make sure it works.

Also the tests have an empty frame, but are non-existent.

@sergeylukin
Copy link

Nice work! Looks good so far.

@balupton
Copy link
Member Author

AWESOME. This progressed way fast! I applied some improvements with docpad/docpad-plugin-ghpages@b89c29c so now just to figure out that loading issue!

So cool!

@deitch
Copy link

deitch commented Feb 11, 2013

Well, not much point in waiting, is there? Might as well do it while it is fresh in all our minds.

@deitch
Copy link

deitch commented Feb 11, 2013

LOL! "... too scary for the average user... "

@zenorocha
Copy link

Looking forward to use this plugin on my docpad projects :)

@balupton
Copy link
Member Author

Alrighty, I've got the necessary changes in DocPad going, just need to do some more testing. Changes here: master...dev-loadearly

Note these changes: 070f9b9#L0R5 - initially I'll do this only when deploy is mentioned in our command, and see how that goes. Just unsure what a double load at this point will do if I enable it for all commands. If it doesn't cause any issue, we can look at making it happen all the time when needed.

@deitch
Copy link

deitch commented Feb 14, 2013

I came across one issue. If you have the livereload plugin, set {load: true}, and run docpad generate --env static, then the livereload JS is still included in the output files. Normally --env static should preclude the livereload JS from being there.

@deitch
Copy link

deitch commented Feb 28, 2013

Hey @balpton, how goes this issue? Happy to have done the work, but want it to benefit.

@balupton
Copy link
Member Author

balupton commented Mar 4, 2013

Fixed the loading issue, however just got back from holidays so haven't had a chance to push it all up. Will be coming soon.

@balupton
Copy link
Member Author

balupton commented Mar 6, 2013

Done.

v2.0.0 of docpad-plugin-ghpages now out
v6.24.0 of docpad now out

🍰

Well done everyone! Great team effort :) 👍

@balupton balupton closed this as completed Mar 6, 2013
@deitch
Copy link

deitch commented Mar 9, 2013

Awesome @balupton really was a great team effort.

Do you need 6.24.0 or higher to use it?

@balupton
Copy link
Member Author

balupton commented Mar 9, 2013

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants