Is there a way to use a pre/post commit hook in github to update gh-pages branch from master?

北慕城南 提交于 2019-12-21 05:48:07

问题


I have a completely static site (eg. https://github.com/robertjchristian/angular-enterprise-seed) hosted on github, where I work mostly out of the master branch. The contents of the /app/ directory are byte-for-byte what I want to host. So during development I just cd ~/projects/angular-enterprise-seed/app, and then "python -m SimpleHTTPServer". This allows me to browse the site locally at localhost:8000.

I want to host the static contents of /app on the web as well, and gh-pages is the ideal candidate. Here are my requirements:

  • Don't want to "just use gh-pages branch as master"
  • Don't want to rely on a wrapper script that keeps gh-pages in line with master changes from the client.
  • Don't want to build out a service to handle the webhook post, checkout from master, and check into gh-pages.

Ideally it would be a github hook that says "Post commit hook - sync gh-pages with change in master"

Any ideas?

Thanks.


回答1:


After reading through a variety of different solutions for handling the sync between master and gh-pages, I ended up adopting an approached favored by JavaScript guru Sindre Sorhus and others:

  1. Make the gh-pages branch the default one on GitHub
  2. Delete the master branch
  3. Use the gh-pages branch as master.

You can see this on GitHub in Sindre's screenful.js repo, or in my project, selection-menu.



来源:https://stackoverflow.com/questions/15285324/is-there-a-way-to-use-a-pre-post-commit-hook-in-github-to-update-gh-pages-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!