Skip to content

Instantly share code, notes, and snippets.

@b-wilder
Last active February 12, 2022 15:58
Show Gist options
  • Save b-wilder/e4fdeec6673413d343676d0bf849f322 to your computer and use it in GitHub Desktop.
Save b-wilder/e4fdeec6673413d343676d0bf849f322 to your computer and use it in GitHub Desktop.
Deploy only the deltas
#Azure DevOps / Powershell example
$priorVersionNumber = $args[0] #Assumption: you have the version number the prior deployment to this environment was tagged with
$newVersionNumber = $args[1] #Assumption: you have the new version number to tag the new commit with
$environment = $args[2] #Assumption: you have the name of the environment you are deploying to
$releaseCommit = $args[3] #Assumption: you have the id of the commit you are deploying
Invoke-Expression "git checkout $releaseCommit"
#Use the SFDX Git Delta plugin to deploy the delta between the checked out release commit and the tag last deployed to the current environment
#https://www.npmjs.com/package/sfdx-git-delta
$deploymentResponse = Invoke-Expression "sfdx sgd:source:delta --to HEAD --from $priorVersionNumber --output . --loglevel ERROR"
#tag and update variable if deployment was successful
if($deploymentResponse -eq $null) {
Invoke-Expression "git tag -a $newVersionNumber"
#Azure DevOps Example - update your variable group to indicate the latest version / tag that was deployed to the environment
Invoke-Expression "az pipelines variable-group variable update --group-id sfRelease --name $environment --value $newVersionNumber"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment