Fixed the get-codeowner in release step. (#3130)

This commit is contained in:
Sima Zhu 2021-11-22 17:31:43 -08:00 committed by GitHub
parent 1a5c3f7f30
commit b28496a9fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,47 +170,14 @@ stages:
CloseAfterOpenForTesting: '${{ parameters.TestPipeline }}'
- pwsh: |
# "person1,person2,Azure/group-name,person3" ->
# "@person1, @person2, @person3"
function getFormattedNotifableOwners($rawOwners) {
# If the list of owners is empty return an emtpy
# string
if (!$rawOwners) {
return ''
}
$owners = @()
foreach ($owner in $rawOwners -split ',') {
# Exclude groups. GitHub does not notify teams
# that have different owners (e.g. alerting
# @Azure/example-team when opening a PR in
# Microsoft/vcpkg)
if ($owner.indexOf('/') -ne -1) {
continue
}
$owners += "@$owner"
}
return $owners -join ', '
}
$prOwners = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 `
$codeOwnersToNotify = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 `
-TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/" `
-RootDirectory "$(Build.SourcesDirectory)"
$codeOwnersToNotify = getFormattedNotifableOwners -rawOwners $prOwners
# If there are no codeowners fall back to owners of /sdk/
if (!$codeOwnersToNotify) {
$fallbackOwners = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 `
-TargetDirectory "/sdk/" `
-RootDirectory "$(Build.SourcesDirectory)"
$codeOwnersToNotify = getFormattedNotifableOwners -rawOwners $fallbackOwners
}
-CodeOwnerFileLocation "$(Build.SourcesDirectory)/.github/CODEOWNERS"
$prComment = "Adding ${{ artifact.Name }} to release"
if ($codeOwnersToNotify) {
$prComment += "`n`ncc: $codeOwnersToNotify"
$codeOwners = $codeOwnersToNotify.ForEach({ "@$_" }) -join ", "
$prComment += "`n`ncc: $codeOwners"
}
./eng/common/scripts/Add-IssueComment.ps1 `