Fixed the get-codeowner in release step. (#3130)
This commit is contained in:
parent
1a5c3f7f30
commit
b28496a9fb
@ -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 `
|
||||
|
||||
Loading…
Reference in New Issue
Block a user