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:
Daniel Jurek 2023-10-12 11:49:30 -07:00 committed by GitHub
parent c9f3b9485e
commit f437eb0f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 6 deletions

3
.vscode/cspell.json vendored
View File

@ -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",

View File

@ -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 `

View 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)"