diff --git a/build/stage-determine-changes.yml b/build/stage-determine-changes.yml index e9df1022e..db74001cd 100644 --- a/build/stage-determine-changes.yml +++ b/build/stage-determine-changes.yml @@ -6,11 +6,10 @@ jobs: steps: - powershell: | # Determine the context of the build (PR or push) and set the target branch accordingly - $prTargetBranch = "$(System.PullRequest.TargetBranch)" - $isPR = -not [string]::IsNullOrWhiteSpace($prTargetBranch) + $isPR = "$(Build.Reason)" -eq "PullRequest" # Normalize the target branch name for PR builds or default to 'master' for push builds - $targetBranchName = $isPR ? $prTargetBranch -replace 'refs/heads/', '' : "master" + $targetBranchName = $isPR ? "$(System.PullRequest.TargetBranch)" -replace 'refs/heads/', '' : "master" Write-Host "Build context determined: $(if ($isPR) { 'Pull Request targeting ' + $targetBranchName } else { 'Push' })" # Fetch the target or default base branch and determine the merge base