-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline configuration for cleaning up upstream branches (#1088)
- Add Cleanup pipeline. - The intention is to run this on a schedule. The first step here is for cleaning up `eng sommon sync` branches.
- Loading branch information
1 parent
d4b5190
commit edf1b48
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
param( | ||
$RepoOwner, | ||
$RepoName, | ||
$BranchPrefix, | ||
$AuthToken | ||
) | ||
|
||
. "${PSScriptRoot}\common.ps1" | ||
|
||
LogDebug "Operating on Repo [ $RepoName ]" | ||
try{ | ||
$branches = (List-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix").ref | ||
} | ||
catch { | ||
LogError "List-References failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
foreach ($branch in $branches) | ||
{ | ||
try { | ||
$branchName = $branch.Replace("refs/heads/","") | ||
$head = "${RepoOwner}/${RepoName}:${branchName}" | ||
LogDebug "Operating on branch [ $branchName ]" | ||
$pullRequests = List-PullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head | ||
} | ||
catch | ||
{ | ||
LogError "List-PullRequests failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
if ($pullRequests.Count -eq 0) | ||
{ | ||
LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated Pull Request. Deleting Branch" | ||
try{ | ||
Delete-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref ($branch.Remove(0,5)) -AuthToken $AuthToken | ||
} | ||
catch { | ||
LogError "Delete-References failed with exception:`n$_" | ||
exit 1 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
parameters: | ||
- name: Repos | ||
type: object | ||
default: | ||
- azure-sdk-for-android | ||
- azure-sdk-for-c | ||
- azure-sdk-for-cpp | ||
- azure-sdk-for-go | ||
- azure-sdk-for-ios | ||
- azure-sdk-for-java | ||
- azure-sdk-for-js | ||
- azure-sdk-for-net | ||
- azure-sdk-for-python | ||
|
||
jobs: | ||
- job: CleanUp | ||
pool: | ||
vmImage: windows-2019 | ||
steps: | ||
- ${{ each repo in parameters.Repos }}: | ||
- task: PowerShell@2 | ||
displayName: Clean Up Sync Common Branches | ||
condition: succeeded() | ||
inputs: | ||
pwsh: true | ||
workingDirectory: $(System.DefaultWorkingDirectory) | ||
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1 | ||
arguments: > | ||
-RepoOwner "Azure" | ||
-RepoName ${{ repo }} | ||
-BranchPrefix "sync-eng/common-" | ||
-AuthToken $(azuresdk-github-pat) |