2

Before I state my question, I'd like to point out that I may be going about my goal entirely wrong, so please let me know if I am.

What I'm trying to do is to have my personal website pull in code from a github repo that I'm going to set up for an HTML5/JavaScript game. Whenever I commit to the repo, I'd like for the site to pull in the updated code and serve that up to users. I saw in another similar question how to link directly to the source files on GitHub, but I feel like this would be an unfair abuse of GitHub's hosting capabilities.

So, would this be some kind of chron job or script that I have running on the site? Or does GitHub perhaps provide some sort of API that could trigger a callback to git-pull on a commit?

CJ McAllister
  • 291
  • 3
  • 10
  • 20
  • Not sure about github's policies, but using github as a CDN seems to be a common practice. There are also entire websites hosted on github (see pages.github.com ). – kapex Dec 15 '12 at 22:39
  • I would just create a `commit` script and handle it there. Then you run the script whenever you want to commit and update. – elclanrs Dec 15 '12 at 22:40
  • @elclanrs That's what I figured I'd end up doing, but I'd like it to be automated somehow, preferably via callback, and secondarily via chron jobs or something similar (not sure if my free hosting account is allowed chron jobs). Do you know if GitHub provides this callback in some capacity? – CJ McAllister Dec 15 '12 at 22:43
  • @kapep I'm looking for cross-browser-y goodness, and it seems that using GitHub as a CDN messes that up due to some kind of content-type mangling or some such EDIT: more info [here](http://stackoverflow.com/a/5503156/503585) – CJ McAllister Dec 15 '12 at 22:44

1 Answers1

1

Here is a guide that may work. You're basically setting up a git repo on the server and pushing to it. The better way is in the article listed. The hacky way that I've done is to simply clone the repo on the machine and pull changes from a production branch. Terrible idea.

  • Thanks for the link; had to resolve some hosting issues, but now that that's done I'll look into it and report back. – CJ McAllister Dec 16 '12 at 16:39
  • Github probably has an endpoint for when a new push has been made, so you can have a script that makes a request at set intervals to check for changes. Then, just ```git push production master``` –  Dec 16 '12 at 18:06
  • 1
    Checked it out, and git-deploy is definitely what I'm looking for, thanks! – CJ McAllister Dec 31 '12 at 03:47