Skip infrastructure deployments if there are no changes to deploy (Azure Pipelines)
One devops strategy is to keep infrastructure state and code in a single repository, and deploy them together. It ensures your infrastructure is always in the correct state to match the version of your code.
The downside is that infrastructure deployments are slow, and generally don't change as frequently as code.
This gist shows how to skip an infrastructure deployment task if there are no changes in a particular sub-path of the repository.
It takes advantage of the pipelines API, which can provide a list of all commits since the last successful pipeline execution. This ensures that it works even when multiple commits are pushed at once, or when the build with the infrastructure change failed. The pipelines API does the hard work of working out which commits need checking.