Eng workflows sync and branch cleanup additions (#4611)
Co-authored-by: James Suplizio <jasupliz@microsoft.com>
This commit is contained in:
parent
495ee2ddf9
commit
e08c281cac
@ -19,5 +19,15 @@ steps:
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
displayName: Prevent changes to eng/common outside of azure-sdk-tools repo
|
||||
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-.github/workflows")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
|
||||
{
|
||||
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath '.github/workflows/*'
|
||||
if (($LASTEXITCODE -eq 0) -and ($filesInCommonDir.Count -gt 0))
|
||||
{
|
||||
Write-Host "##vso[task.LogIssue type=error;]Changes to files under '.github/workflows' 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 .github/workflows outside of azure-sdk-tools repo
|
||||
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'), not(endsWith(variables['Build.Repository.Name'], '-pr')))
|
||||
@ -10,6 +10,7 @@ param(
|
||||
$CentralRepoId,
|
||||
# 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.
|
||||
# For sync-eng/common work, we use regex as "^sync-eng/common.*-(?<PrNumber>\d+).*$".
|
||||
# For sync-.github/workflows work, we use regex as "^sync-.github/workflows.*-(?<PrNumber>\d+).*$".
|
||||
$BranchRegex,
|
||||
# Date format: e.g. Tuesday, April 12, 2022 1:36:02 PM. Allow to use other date format.
|
||||
[AllowNull()]
|
||||
@ -69,7 +70,7 @@ foreach ($res in $responses)
|
||||
LogError "No PR number found in the branch name. Please check the branch name [ $branchName ]. Skipping..."
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$centralPR = Get-GitHubPullRequest -RepoId $CentralRepoId -PullRequestNumber $pullRequestNumber -AuthToken $AuthToken
|
||||
LogDebug "Found central PR pull request: $($centralPR.html_url)"
|
||||
@ -78,7 +79,7 @@ foreach ($res in $responses)
|
||||
continue
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
# If there is no central PR for the PR number, log error and skip.
|
||||
LogError "Get-GitHubPullRequests failed with exception:`n$_"
|
||||
@ -107,15 +108,15 @@ foreach ($res in $responses)
|
||||
LogDebug "The branch $branch last commit date [ $commitDate ] is newer than the date $LastCommitOlderThan. Skipping."
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
LogDebug "Branch [ $branchName ] in repo [ $RepoId ] has a last commit date [ $commitDate ] that is older than $LastCommitOlderThan. "
|
||||
}
|
||||
catch {
|
||||
LogError "Get-GithubReferenceCommitDate failed with exception:`n$_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
if ($PSCmdlet.ShouldProcess("[ $branchName ] in [ $RepoId ]", "Deleting branches on cleanup script")) {
|
||||
Remove-GitHubSourceReferences -RepoId $RepoId -Ref $branch -AuthToken $AuthToken
|
||||
|
||||
Loading…
Reference in New Issue
Block a user