azure-sdk-tools/eng/pipelines/branch-cleanup.yml

186 строки
7.0 KiB
YAML

parameters:
- name: WhatIfPreference
type: boolean
default: false
- name: Repos
type: object
default:
- Azure/azure-sdk
- Azure/azure-sdk-for-android
- Azure/azure-sdk-for-c
- Azure/azure-sdk-for-cpp
- Azure/azure-sdk-for-go
- Azure/azure-sdk-for-ios
- Azure/azure-sdk-for-java
- Azure/azure-sdk-for-js
- Azure/azure-sdk-for-net
- Azure/azure-sdk-for-python
- Azure/azure-sdk-for-rust
- name: ForkAutomationBranches
type: object
default:
- azure-sdk/azure-powershell
- azure-sdk/azure-sdk-for-go
- azure-sdk/azure-sdk-for-java
- azure-sdk/azure-sdk-for-js
- azure-sdk/azure-sdk-for-net
- azure-sdk/azure-sdk-for-python
- name: SDKPrivate
type: object
default:
- Azure/azure-powershell-pr
- Azure/azure-sdk-for-go-pr
- Azure/azure-sdk-for-java-pr
- Azure/azure-sdk-for-js-pr
- Azure/azure-sdk-for-net-pr
- Azure/azure-sdk-for-python-pr
- azure-sdk/azure-powershell-pr
- azure-sdk/azure-sdk-for-go-pr
- azure-sdk/azure-sdk-for-java-pr
- azure-sdk/azure-sdk-for-js-pr
- azure-sdk/azure-sdk-for-net-pr
- azure-sdk/azure-sdk-for-python-pr
- name: DailyBranchRepos
type: object
default:
- Azure/azure-docs-sdk-dotnet
- Azure/azure-docs-sdk-java
- MicrosoftDocs/azure-docs-sdk-node
- MicrosoftDocs/azure-docs-sdk-python
- name: RestAPISpecsDocsRepos
type: object
default:
- MicrosoftDocs/AzureRestPreview
jobs:
- job:
displayName: Branch Clean-up
pool:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04
variables:
- template: /eng/pipelines/templates/variables/globals.yml
steps:
- pwsh: |
gh --version
pwsh --version
displayName: Dump tool versions
- ${{ each repo in parameters.Repos }}:
- task: PowerShell@2
displayName: ${{ repo }} sync eng/common branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-CentralRepoId "Azure/azure-sdk-tools"
-BranchRegex "^sync-eng/common.*-(?<PrNumber>\d+).*$"
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- task: PowerShell@2
displayName: ${{ repo }} sync workflow branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-CentralRepoId "Azure/azure-sdk-tools"
-BranchRegex "^sync-.github/workflows.*-(?<PrNumber>\d+).*$"
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- ${{ each repo in parameters.ForkAutomationBranches }}:
- task: PowerShell@2
displayName: ${{ repo }} automation branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-BranchRegex "^(increment-package-version-|fluent-lite-generation-|auto-update-|version-increment-build-|post-release-automation-|restapi_auto_|t2-).*$"
-LastCommitOlderThan ((Get-Date).AddDays(-1))
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- task: PowerShell@2
displayName: ${{ repo }} swagger public SDK PR and branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-CentralRepoId "Azure/azure-rest-api-specs"
-BranchRegex "^sdkAuto/(?<PrNumber>\d+)/.*$"
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- ${{ each repo in parameters.SDKPrivate }}:
- task: PowerShell@2
displayName: ${{ repo }} swagger private SDK PR and branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-CentralRepoId "Azure/azure-rest-api-specs-pr"
-BranchRegex "^sdkAuto/(?<PrNumber>\d+)/.*$"
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- ${{ each repo in parameters.DailyBranchRepos }}:
- task: PowerShell@2
displayName: ${{ repo }} daily docs branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoId "${{ repo }}"
-BranchRegex "^daily"
-LastCommitOlderThan ((Get-Date).AddDays(-7))
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}
- ${{ each repo in parameters.RestAPISpecsDocsRepos }}:
- task: PowerShell@2
displayName: ${{ repo }} azure-rest-api-specs docs branch clean-up
condition: succeededOrFailed()
continueOnError: true
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
# TODO: 00a0dc86-3419-4dd5-b119-e83edaf17e7e needs to be skipped because it's the default
# branch for the repository. This will be removed once the default branch has been changed
# to main
arguments: >
-RepoId "${{ repo }}"
-BranchRegex "^(result_)?(?!00a0dc86-3419-4dd5-b119-e83edaf17e7e)([0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-)|(openapiHub_production_)|(openapiHub_preproduction_)[0-9a-z]{12}$"
-LastCommitOlderThan ((Get-Date).AddDays(-14))
-AuthToken $(azuresdk-github-pat)
-WhatIf:$${{parameters.WhatIfPreference}}