--- title: Publishing Sculpin Sites with GitHub Pages tags: [sculpin, php, github] meta: description: 'How I moved my Sculpin site to GitHub Pages.' og: image: url: '/assets/images/blog/jackson-octocat.png' type: 'image/png' height: 200 width: 451 --- {% block excerpt %}
This means that I can simply re-generate the site after making changes and add it as an additional commit to my main branch with no need to switch branches or perform a merge.
To simplify this, I’ve added a new [publish.sh script][3] into my repository to automate the sites. This is how it currently looks:
```language-bash
#!/usr/bin/env bash
SITE_ENV="prod"
# Remove the existing docs directory, build the site and create the new
# docs directory.
rm -rf ./docs
vendor/bin/sculpin generate --no-interaction --clean --env=${SITE_ENV}
touch output_${SITE_ENV}/.nojekyll
mv output_${SITE_ENV} docs
# Ensure the correct Git variables are used.
git config --local user.name 'Oliver Davies'
git config --local user.email oliver@oliverdavies.uk
# Add, commit and push the changes.
git add --all docs
git commit -m 'Build.'
git push origin HEAD
```
This begins by removing the deleting the existing `docs` directory and re-generating the site with the specified environment. Then I add a `.nojekyll` file and rename the output directory to replace `docs`.
Now the changes can be added, committed and pushed. Once pushed, the new code is automatically served by GitHub Pages.
## HTTPS
GitHub Pages unfortunately does [not support HTTPS for custom domains][7].
As the site was previously using HTTPS, I didn’t want to have to go back to HTTP, break any incoming links and lose any potential traffic. To continue using HTTPS, I decided to [use Cloudflare][6] to serve the site via their CDN which does allow for HTTPS traffic.
## Next Steps
- Enable automatically running `publish.sh` when new changes are pushed to GitHub rather than running it manually. I was previously [using Jenkins][4] and Fabric for this, though I’m also going to look into using Travis to accomplish this.
- Add the pre-build steps such as running `composer install` and `yarn` to install dependencies, and `gulp` to create the front-end assets. This was previously done by Jenkins in my previous setup.
## Resources
- [Publishing your GitHub Pages site from a /docs folder on your master branch][2]
- [Bypassing Jekyll on GitHub Pages][5]
- [Secure and fast GitHub Pages with CloudFlare][6]
{% endblock %}
[0]: https://pages.github.com
[1]: https://github.com/opdavies/oliverdavies.uk
[2]: https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch
[3]: https://github.com/opdavies/oliverdavies.uk/blob/master/publish.sh
[4]: /blog/2015/07/21/automating-sculpin-jenkins
[5]: https://github.com/blog/572-bypassing-jekyll-on-github-pages
[6]: https://blog.cloudflare.com/secure-and-fast-github-pages-with-cloudflare
[7]: https://github.com/blog/2186-https-for-github-pages