-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy patheng-common-workflow-enforcer.yml
More file actions
38 lines (36 loc) · 2.37 KB
/
eng-common-workflow-enforcer.yml
File metadata and controls
38 lines (36 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# cSpell:ignore changedfiles
# cSpell:ignore Committish
# cSpell:ignore LASTEXITCODE
steps:
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
# Find the default branch of the repo. The variable value sets in build step.
Write-Host "Default Branch: $(DefaultBranch)"
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-eng/common")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
{
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath 'eng/common/*' -DiffFilterType ""
if ($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/main/doc/common/common_engsys.md"
exit 1
}
}
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-.github")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
{
# This list needs to be kept in sync with the FilePatterns listed in eng/pipelines/eng-github-config-sync.yml
$filePatterns = @(".github/workflows/*event*", ".github/workflows/post-apiview.yml", ".github/skills/azsdk-common-*/**")
$filesInCommonDir = @()
foreach ($filePattern in $filePatterns) {
$filesInCommonDir += & "eng/common/scripts/get-changedfiles.ps1" -DiffPath $filePattern -DiffFilterType ""
}
if ($filesInCommonDir.Count -gt 0)
{
Write-Host "##vso[task.LogIssue type=error;]Changes to selected files under '.github/' 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/main/doc/workflows/engsys_workflows.md"
exit 1
}
}
displayName: Prevent changes to eng/common and selected .github/* files outside of azure-sdk-tools repo
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'), not(endsWith(variables['Build.Repository.Name'], '-pr')))