azure-sdk-for-cpp/eng/scripts/Get-TriggeringUserGitHubAlias.ps1
Daniel Jurek f437eb0f23
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)
2023-10-12 11:49:30 -07:00

29 lines
694 B
PowerShell

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