ELI5: Rich Seal's SXA Creative Exchange CI/CD Integration
June 07, 2021
Overview of SXA Creative Exchange
SXA's Creative Exchange helps separate FED workflows from BED workflows. It's a set of tooling and processes that help import and export theme-related files to/from Sitecore - FEDs can work in isolation with markup, then import the completed styling and scripts back into Sitecore.
With local development, this is easy to do with the SXA CLI tooling, but deployments to higher environments can be tricky when dealing with FED assets - how can a CI/CD process utilizie the SXA CLI tooling to compile and upload asset files into Sitecore?
A Modern Solution
Rich Seal detailed a clever way of solving this problem with the help of a Unicorn sync. I highly recommend reading Rich's article before and after this one - my goal here is to explain Rich's process in simple terms, but his article ultimately describes important details.
while Rich's solution is a clever process, it's not very straightforward to understand, so here's the ELI5 version.
ELI5: Syncing & Deploying SXA Theme Files Via Unicorn
Step 1: Configure Unicorn to partially sync the
pre-optimized-minscript/style files on developer machines; this prevents blob-related data from causing merge conflicts with source control.
Step 2: Use a script during the CI build process to run the SXA CLI
buildcommand; this generates compiled
pre-optimized-minfiles from source.
Step 3: Use a script to populate the
pre-optimized-minUnicorn YAML files with base64-encoded scripts/styles content. This is where the
sizefields get re-populated.
With these changes, the Unicorn sync step of your release process will simply sync the latest script/style changes into Sitecore without any futher pipeline changes.
Why not just run the build+upload SXA CLI commands as part of the CI build process?
It may seem obvious to just build assets from source and upload them into Sitecore using the SXA CLI during the CI/CD process, but there are a few potential roadblocks:
Sitecore needs to be started, which means uploading FED assets would have to wait until later stages of the release pipeline.
Uploading into Sitecore requires credentials - where in your CI/CD pipeline would you store those credentials?
While the SXA CLI
buildcommand is obvious, how do you know which environment to target when issuing the
uploadcommand (dev, staging, integration, production, etc.)?
Do you have questions, comments, or corrections for this post? Find me on Twitter: @BrandonMBruno