This post is the fourth in a series of deployment workflows I use to get code into production.
This is the one non-WordPress deployment writeup, though still interesting.
The WSU Spine plays the role of both branding and framework for websites created at WSU. It provides a consistent navigation experience, consistent default styles, and the proper University marks. At the same time, a fully responsive CSS framework makes it easy for front end developers at WSU to create mobile friendly pages. For sites that are in the WSUWP Platform, we provide a parent theme that harnesses this framework.
One of the great parts about maintaining a central framework like this is being able to serve it from a single location –
repo.wsu.edu – so that the browsers of various visitors can cache the file once and not be continually downloading Spine versions while they traverse the landscape of WSU web.
It took us a bit to get going with our development workflow, but we finally settled on a good model later in 2014 centered around semantic versioning. We now follow a process similar to other libraries hosted on CDNs.
spine.min.css for our current version 1.2.2 are provided at:
repo.wsu.edu/spine/1/*– Files here are cached for an hour. This major version URL will always be up to date with the latest version of the Spine. If we break backward compatibility, the URL will move up a major version to
/spine/2/so that we don’t break live sites. This is our most popular URL.
repo.wsu.edu/spine/1.2.2– Files here are cached for 120 days. This is built for every minor and patch release. This allows for longer cache times and fine grained control in their own projects. It does increase the chance that older versions of the Spine will be in the wild. We still have not seen any traffic on this URL yet.
repo.wsu.edu/spine/develop/– Files here are cached for 10 minutes. This is built every time the develop branch is updated in the repository and is considered bleeding edge and often unstable.
So, our objectives:
- Deploy to one directory for every change to
- Deploy to the major version directory whenever a new release is tagged.
- Create and deploy to a minor/patch version directory whenever a new release is tagged.
As with the WSUWP Platform, we use GitHub’s webhooks. For this deployment process, we watch for both the
push events using a very basic PHP script on the server rather than a plugin.
Here’s a shorter version of that script embedded:
- If we receive a
pushevent and it is on the
developbranch, then we fire a deploy script with
developas the only argument.
- If we receive a
createevent and it is for a new tag that matches our
#.#.#convention, then we fire a deploy script with this tag as the only argument.
And here’s the deploy script that it’s firing:
The brief play by play from the script above is:
- Get things clean in the current repo.
- Checkout whichever branch or tag was passed as the argument.
- Update NPM dependencies.
grunt prodto run through our build process.
- Move files to the appropriate directories.
Really, really smooth. Also really, really basic and ugly. 🙂
We’ve actually only done 2 or 3 releases with this model so far, so I’m not completely convinced there aren’t any bugs. It’s pretty easy to maintain as there really are few tasks that need to be completed. Build files, get files to production.
Another great bonus is the Spine version switcher we have built as a WordPress Customizer option in the theme. We can go to any site on the platform and test out the develop branch if needed.
In the near future, I’d like to create directories for any new branch that is created in the repository. This will allow us to test various bug fixes or new features before committing them to develop, making for a more stable environment overall.
As with other posts in the series, I would love feedback! Please leave a comment or reach out with suggestions or questions.
The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.
Learn more about Webmentions.