Roots Discourse

Compiling theme on deployment

Hi there,
I’ve been building my themes using roots for a while now (and still loving it). My workflow has been…

  1. Host theme in bitbucket repo
  2. DeployBot monitors the repo and when it detects a commit, compiles the theme (eg dynamically creates /dist)
  3. DeployBot then deploys the relevant files to my server via FTP

The compilation of the theme upon each deployment has seemed like a necessary step in order to reproduce and overwrite the existing /dist folder on the server as opposed to merging changes (as a lot of the css/js is minified, I’ve thought this can get messy - correct me if I’m wrong).

I’m now getting to the point where DeployBot’s build tools often errors/fails, sometimes for no apparent reason (which is especially frustrating when I really need to get an update out). I need to adjust my workflow to something a little more stable. Of course I still want to utilise roots/gulp however not quite sure what the happy medium is so that I’m not compiling my theme each time upon deployment.

Can someone recommend something that works for them?

Trellis!

It is possible to commit the /dist folder to the repo but it makes for a messy developer workflow and (unnecessarily) increases the size of the repo so compiling on each deployment is (for me) the smarter way to do it.

Austin has a good post on this at http://austinpray.com/ops/2015/01/15/build-steps-and-deployment.html

I’d still recommend compiling on each deployment and Trellis makes this easy by scripting it with Ansible.

You’d simply have to type ./deploy.sh <environment> <site name> and it will (after you’ve uncommented the example deploy hook):

  • pull down the git repo to the server
  • run composer install to build the “backend” dependencies
  • run gulp --production on your local machine and copy these files to the server

Trellis also removes the need to manually provision servers, something DeployBot can’t do :wink:

3 Likes