diff --git a/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml b/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml new file mode 100644 index 000000000000..7163d2badf76 --- /dev/null +++ b/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml @@ -0,0 +1,13 @@ +steps: + - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + - pwsh: | + $filesInCommonDir = git diff "origin/$(System.PullRequest.TargetBranch)" HEAD --name-only -- 'eng/common/*' + + if ((-not $PrSourceBranch.StartsWith("sync-eng/common")) -and ($filesInCommonDir.Count -gt 0)) + { + Write-Host "##vso[task.LogIssue type=error;]Changes to files under 'eng/common' directory should not be made in this Repo`n${filesInCommonDir}" + Write-Host "##vso[task.LogIssue type=error;]Please follow workflow at https://github.com/Azure/azure-sdk-tools/blob/master/doc/common/common_engsys.md" + exit 1 + } + displayName: Prevent changes to eng/common outside of azure-sdk-tools repo + condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'))