A Jekyll Hook to Copy Pre-Built Site to Another Directory
This site doesn’t build as a GitHub Page as it uses unsupported gems and plugins. So when I push to jamesstout.github.io.git
I get build failures.
My solution is to have two repositories, the source where I write and build the site, and a destination repo that points to the jamesstout.github.io.git
repo. The difference is, the destination repo just contains the files from the already built _site
folder. This is what is pushed to the destination, and ultimately rendered at jamesstout.github.io.
Not wanting to do anything manually, I wrote a Jekyll hook plugin that copies the files from the _site
folder to the destination repo, commits the changes and pushes to its remote, but only if there is a new commit in the source repo. No point copying, and pushing if you haven’t yet committed your changes. Here’s the plugin: