I have a simple static website, based on HTML 5 boilerplate and the whole thing is in a github repository. The project structure is something like this
build
Since .gitignore
is versioned as well, just don't put the publish/
directory in the gh-pages
branch's .gitignore
file. Then, you can just do something like this:
ORIG_HEAD="$(git name-rev --name-only HEAD)" git checkout gh-pages && mv publish/* . && git commit -am "automatic update" && git checkout "$ORIG_HEAD"
It does get tricky since you're wanting to do things in the root directory rather than a subdirectory. Another option would be to simply maintain a separate clone of the same repository in a different directory, that is always on the gh-pages
branch. You could have your script just write the files to there instead of to publish/
and then just commit in that clone.