Locally compiled Sage assets on Trellis deploy

The deployment workflow for Trellis will compile Sage assets from local files, and use them for deployment, regardless of which environment is being deployed to.

Our git setup is essentially this:

  • master branch (always deploy to ‘production’ environment)
  • staging branch (always deploy to ‘staging’ environment)
  • development branches (any number of feature branches, to merge into staging then master)

ie. In the scenario that someone wants to deploy to ‘staging’ with Trellis, once files are committed to the staging repo, that person then also needs to make sure they switch their local branch to match staging prior to deployment, otherwise the incorrect assets will be deployed.

Is this perhaps a workflow that might be reconsidered, or should we simply make sure anyone making a deploy ensures their local assets are match the repo branch that is being deployed?

To me it could be a bit error prone, but just wondering if its in your line of sight.

This is a good point that I’ve somehow never thought of. Since Trellis is issuing local commands and knows the branch being deployed, we could possible just run git checkout <branch> locally.

You could easily add this to the deploy role to try it out.

Sounds good, how might that deal with locally modified files however if these aren’t yet committed or stashed?

I’d do a check first and throw a warning and abort the deploy. No one should be deploying with their folder in a dirty state.