I very much like the Sculpin project. It builds on solid components like Composer and Symfony. Thus being PHP, which is my language of choice, it makes it easy for me to configure and extend where needed. I can read up and comprehend every bit that happens inside it and that is very helpful.
Having used Sculpin now for the rokka.io website, I was eager to make it more comfortable, as in having it auto deploy. The requirements were simple. Have the code live public in Github, then auto deploy on merges to the master branch, while not needing any more tools or servers that would cost me something extra. The same requirement I have for other projects, so this will benefit those as well.
I’m deploying to an S3 bucket from which I serve the pages, but you can also do it with pretty much anything else. S3 has the advantage that it’s simple and relative cheap for small and medium static sites, often times not even cracking the free tier you get as a customer of AWS. Also zero system administration for you to do, it just runs.
Now what I’m using here is the documented features of Travis CI. It’s free and works amazingly well for this purpose.
Make a file called “.travis.yml” in the main directory. Here is mine from rokka:
language: php
php:
- '7.0'
install:
- composer install
script: vendor/sculpin/sculpin/bin/sculpin --env=prod generate
deploy:
# How to deploy to S3: https://docs.travis-ci.com/user/deployment/s3/
provider: s3
# To store these securely, here is how to encrypt: https://docs.travis-ci.com/user/encryption-keys/
access_key_id:
secure: "FnJ--snip"
secret_access_key:
secure: "Bw4--snip"
bucket: "rokka-io-site"
region: "eu-central-1"
skip_cleanup: true
local_dir: output_prod
on:
branch: master
Now the first blocks tell travis to use PHP, that you want to run this under PHP 7, then run a composer install (so you have all components to build) and the script line does the actual generation of the site.
So far so good but now your files are on the VM of travis and you want them to go somewhere else. Travis CI supports already a lot of deployment ways. And if your way isn’t there, you can just supply your custom script.
The provider line tells Travis what I want to use, in this case, S3. Access key and secret are a bit weird. Why would you want yours to be public? Well turns out you can encrypt them, store them in a public file, and only Travis will be able to decrypt them again. Bucket is your S3 bucket (duh) and the region is of course the region you want to store it. Mine here is eu-central-1, you might want to choose another or just not specify it for a good default.
The next three lines are more interesting. The skip cleanup means that Travis will not try to wipe the directory clean again (and thus destroying the built site) for the deploy. The local dir is what Travis will deploy, here the built site. With the on clause you tell Travis when to do the deploy, here it says only on the master branch.
So instead of running tests, this runs the build of the site. This has the added side effect that if building the site fails, Travis will inform you and it will not overwrite your current page.
With this setup deploys are as easy as merge to master branch now. And you can spend more time working on your page and less on everything around it.