Skip to content

Commit e1a6152

Browse files
Eng workflows sync and branch cleanup additions (#20743)
Co-authored-by: James Suplizio <[email protected]>
1 parent 8bc3450 commit e1a6152

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,15 @@ steps:
1919
exit 1
2020
}
2121
}
22-
displayName: Prevent changes to eng/common outside of azure-sdk-tools repo
22+
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-.github/workflows")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
23+
{
24+
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath '.github/workflows/*'
25+
if (($LASTEXITCODE -eq 0) -and ($filesInCommonDir.Count -gt 0))
26+
{
27+
Write-Host "##vso[task.LogIssue type=error;]Changes to files under '.github/workflows' directory should not be made in this Repo`n${filesInCommonDir}"
28+
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"
29+
exit 1
30+
}
31+
}
32+
displayName: Prevent changes to eng/common and .github/workflows outside of azure-sdk-tools repo
2333
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'), not(endsWith(variables['Build.Repository.Name'], '-pr')))

eng/common/scripts/Delete-RemoteBranches.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ param(
1010
$CentralRepoId,
1111
# We start from the sync PRs, use the branch name to get the PR number of central repo. E.g. sync-eng/common-(<branchName>)-(<PrNumber>). Have group name on PR number.
1212
# For sync-eng/common work, we use regex as "^sync-eng/common.*-(?<PrNumber>\d+).*$".
13+
# For sync-.github/workflows work, we use regex as "^sync-.github/workflows.*-(?<PrNumber>\d+).*$".
1314
$BranchRegex,
1415
# Date format: e.g. Tuesday, April 12, 2022 1:36:02 PM. Allow to use other date format.
1516
[AllowNull()]
@@ -69,7 +70,7 @@ foreach ($res in $responses)
6970
LogError "No PR number found in the branch name. Please check the branch name [ $branchName ]. Skipping..."
7071
continue
7172
}
72-
73+
7374
try {
7475
$centralPR = Get-GitHubPullRequest -RepoId $CentralRepoId -PullRequestNumber $pullRequestNumber -AuthToken $AuthToken
7576
LogDebug "Found central PR pull request: $($centralPR.html_url)"
@@ -78,7 +79,7 @@ foreach ($res in $responses)
7879
continue
7980
}
8081
}
81-
catch
82+
catch
8283
{
8384
# If there is no central PR for the PR number, log error and skip.
8485
LogError "Get-GitHubPullRequests failed with exception:`n$_"
@@ -107,15 +108,15 @@ foreach ($res in $responses)
107108
LogDebug "The branch $branch last commit date [ $commitDate ] is newer than the date $LastCommitOlderThan. Skipping."
108109
continue
109110
}
110-
111+
111112
LogDebug "Branch [ $branchName ] in repo [ $RepoId ] has a last commit date [ $commitDate ] that is older than $LastCommitOlderThan. "
112113
}
113114
catch {
114115
LogError "Get-GithubReferenceCommitDate failed with exception:`n$_"
115116
exit 1
116117
}
117-
}
118-
118+
}
119+
119120
try {
120121
if ($PSCmdlet.ShouldProcess("[ $branchName ] in [ $RepoId ]", "Deleting branches on cleanup script")) {
121122
Remove-GitHubSourceReferences -RepoId $RepoId -Ref $branch -AuthToken $AuthToken

0 commit comments

Comments
 (0)