Introduction¶
After setting up build automation we also wanted it not to happen only when updating the documentation
repository.
Besides hosting documentation, Elegant website also serves as a live demo of the current release. This meant, the website should be regenerated and updated every time when a documented is added or edited, and also when Elegant theme is updated.
Github and Travis doesn’t offer dependent builds out of the box, so the trick goes to ‘signal’ via a github token to trigger a Travis-CI build.
The technical solution¶
The approach goes via tweaking the ‘test validation’ .travis.yaml
and adding some more steps:
The initial file (similar to the one in our previous article, but for running the ‘page build’ with latest repo checkout) looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
Is then modified to add:
1 2 3 4 5 |
|
This installs Travis-CI utilities and runs a custom script ‘trigger-build.js’ with node, which in turn actually triggers Travis build.
The script, downloaded from Kamran Ayub blog has been edited to specify the ‘repo’ we will trigger and the name of the environment variable containing the token:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
As you can see, in line 14, it grabs the github token from environment variable TRATOKEN
that we’ve defined in
Travis-CI environment for the build.
This is similar to what we did in the documentation repo to push the built website to another repo.
With this solution in place, when a new commit is merged on ‘master’ branch on the ‘theme’ repo (elegant
), Travis does get invoked to schedule a build on the documentation
repo, thus, rendering the live website with latest templates.
Enjoy! Pablo
Comments