Temporary: Fix vcpkg PR notification logic (#5015)
* Fix vcpkg PR notification logic * Clean up fallback accounts, fix cspell errors * Use environment variable for EmailAddress (no logging)
This commit is contained in:
parent
c9f3b9485e
commit
f437eb0f23
3
.vscode/cspell.json
vendored
3
.vscode/cspell.json
vendored
@ -38,10 +38,12 @@
|
||||
"adamdebreceni",
|
||||
"Adls",
|
||||
"ahojnnes",
|
||||
"ahsonkhan",
|
||||
"Aloctl",
|
||||
"AMQP",
|
||||
"AMQPS",
|
||||
"AMQPVALUE",
|
||||
"antkmsft",
|
||||
"azcore",
|
||||
"azsdk",
|
||||
"azsdkengsys",
|
||||
@ -124,6 +126,7 @@
|
||||
"OIDC",
|
||||
"okhttp",
|
||||
"opentelemetry",
|
||||
"Osterman",
|
||||
"otel",
|
||||
"PBYTE",
|
||||
"pdbs",
|
||||
|
||||
@ -193,15 +193,20 @@ stages:
|
||||
OpenAsDraft: ${{ parameters.TestPipeline }}
|
||||
CloseAfterOpenForTesting: '${{ parameters.TestPipeline }}'
|
||||
|
||||
# Workaround: -Fallback uses names from CODEOWNERS who
|
||||
# should be notified about the release in the event of a
|
||||
# failure to resolve the appropriate aliases.
|
||||
- pwsh: |
|
||||
$codeOwnersToNotify = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 `
|
||||
-TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/" `
|
||||
-CodeownersFileLocation "$(Build.SourcesDirectory)/.github/CODEOWNERS"
|
||||
$notifyUsers = ./eng/scripts/Get-TriggeringUserGitHubAlias.ps1 `
|
||||
-EmailAddress "$($env:BUILD_REQUESTEDFOREMAIL)" `
|
||||
-ClientId '$(opensource-aad-app-id)' `
|
||||
-ClientSecret '$(opensource-aad-secret)' `
|
||||
-TenantId '$(opensource-aad-tenant-id)' `
|
||||
-Fallback '@rickwinter @ahsonkhan @antkmsft @gearama @LarryOsterman'
|
||||
|
||||
$prComment = "Adding ${{ artifact.Name }} to release"
|
||||
if ($codeOwnersToNotify) {
|
||||
$codeOwners = $codeOwnersToNotify.ForEach({ "@$_" }) -join ", "
|
||||
$prComment += "`n`ncc: $codeOwners"
|
||||
if ($notifyUsers) {
|
||||
$prComment += "`n`ncc: $notifyUsers"
|
||||
}
|
||||
|
||||
./eng/common/scripts/Add-IssueComment.ps1 `
|
||||
|
||||
28
eng/scripts/Get-TriggeringUserGitHubAlias.ps1
Normal file
28
eng/scripts/Get-TriggeringUserGitHubAlias.ps1
Normal file
@ -0,0 +1,28 @@
|
||||
param(
|
||||
[string] $EmailAddress = $env:BUILD_REQUESTEDFOREMAIL,
|
||||
[string] $ClientId,
|
||||
[string] $ClientSecret,
|
||||
[string] $TenantId,
|
||||
[string] $Fallback
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../common/scripts/Helpers/Metadata-Helpers.ps1"
|
||||
|
||||
$allUsers = GetAllGitHubUsers `
|
||||
-TenantId $TenantId `
|
||||
-ClientId $ClientId `
|
||||
-ClientSecret $ClientSecret
|
||||
|
||||
if (!$allUsers) {
|
||||
Write-Host "Failed to get all GitHub users"
|
||||
return $Fallback
|
||||
}
|
||||
|
||||
$targetUser = $allUsers.Where({ $_.aad.userPrincipalName -eq $EmailAddress -and $_.github.login }, 'First')
|
||||
|
||||
if (!$targetUser) {
|
||||
Write-Host "Failed to find GitHub user for $EmailAddress"
|
||||
return $Fallback
|
||||
}
|
||||
|
||||
return "@$($targetUser.github.login)"
|
||||
Loading…
Reference in New Issue
Block a user