Does anybody have any ti…
Does anybody have any tips on deploying only affected apps in CI?
I’m currently deploying all projects in my CircleCI config vía nx run-many --target=deploy --configuration=production
but, that deploys everything regardless of whether it has changed.
I’m thinking either setting a tag on the latest deployed version that I can pass to affected --base=[last_version]
or maybe set up a separate branch to track the deployed version and FF merge into that at the end of each deploy then use that branch name for the affected
command.
Any advice or tips on other approaches are appreciated. Thanks!
Responses:
I’ve been fighting this same thing. When our PR runs, it updates the cloud cache so the release run finds no changes.
Still ironing it out, but we’ve started creating a git tag on a successful release, then use that tag as the affected base.
So our CI checks for the tag and sets an env var NX_BASE to the sha of the tag if found, or to master if no tag was found. Then on release we set the git tag to point to the latest sha.
FYI, for CircleCI users, there’s a really great/easy solution: The pipeline.git.base_revision
variable. It contains the commit hash for the last commit that triggered the deploy. So, it’s perfect for identifying which projects have changed since the last deploy ran.