SFDX – Deploying Only Diffs

I am setting up a CI process using GitLab and SFDX. Developers do their work in a scratch org, then commit their changes to a QA branch. Upon this commit, the CI pipeline then deploys the entire source (force-app/) to a QA sandbox. We are not currently using unlocked packages.

Instead of deploying the entire source each time, how would it be possible to only deploy the files changed in the latest commit?

I’m thinking something along the lines of using the git diff-tree command to build a list of the changed files, moving these files to a separate directory, using this directory in the sfdx force:source:deploy command, and then deleting the directory. But how to pull this off through a CI pipline, I’m stumped.


Check this: https://www.npmjs.com/package/sfdx-git-delta

It doesn’t move files into a temp dir it instead generates a package.xml referencing only the delta between 2 commits that you can use to deploy only what changed (sfdx force:source:deploy -x ./path to package/package.xml). It seems to be working well, at least on the few tests I did.

Source : Link , Question Author : John_Henry , Answer Author : João Ferreira

Leave a Comment