Skip to content

Commit f437eb0

Browse files
authored
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)
1 parent c9f3b94 commit f437eb0

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

.vscode/cspell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838
"adamdebreceni",
3939
"Adls",
4040
"ahojnnes",
41+
"ahsonkhan",
4142
"Aloctl",
4243
"AMQP",
4344
"AMQPS",
4445
"AMQPVALUE",
46+
"antkmsft",
4547
"azcore",
4648
"azsdk",
4749
"azsdkengsys",
@@ -124,6 +126,7 @@
124126
"OIDC",
125127
"okhttp",
126128
"opentelemetry",
129+
"Osterman",
127130
"otel",
128131
"PBYTE",
129132
"pdbs",

eng/pipelines/templates/stages/archetype-cpp-release.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,20 @@ stages:
193193
OpenAsDraft: ${{ parameters.TestPipeline }}
194194
CloseAfterOpenForTesting: '${{ parameters.TestPipeline }}'
195195

196+
# Workaround: -Fallback uses names from CODEOWNERS who
197+
# should be notified about the release in the event of a
198+
# failure to resolve the appropriate aliases.
196199
- pwsh: |
197-
$codeOwnersToNotify = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 `
198-
-TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/" `
199-
-CodeownersFileLocation "$(Build.SourcesDirectory)/.github/CODEOWNERS"
200+
$notifyUsers = ./eng/scripts/Get-TriggeringUserGitHubAlias.ps1 `
201+
-EmailAddress "$($env:BUILD_REQUESTEDFOREMAIL)" `
202+
-ClientId '$(opensource-aad-app-id)' `
203+
-ClientSecret '$(opensource-aad-secret)' `
204+
-TenantId '$(opensource-aad-tenant-id)' `
205+
-Fallback '@rickwinter @ahsonkhan @antkmsft @gearama @LarryOsterman'
200206
201207
$prComment = "Adding ${{ artifact.Name }} to release"
202-
if ($codeOwnersToNotify) {
203-
$codeOwners = $codeOwnersToNotify.ForEach({ "@$_" }) -join ", "
204-
$prComment += "`n`ncc: $codeOwners"
208+
if ($notifyUsers) {
209+
$prComment += "`n`ncc: $notifyUsers"
205210
}
206211
207212
./eng/common/scripts/Add-IssueComment.ps1 `
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
param(
2+
[string] $EmailAddress = $env:BUILD_REQUESTEDFOREMAIL,
3+
[string] $ClientId,
4+
[string] $ClientSecret,
5+
[string] $TenantId,
6+
[string] $Fallback
7+
)
8+
9+
. "$PSScriptRoot/../common/scripts/Helpers/Metadata-Helpers.ps1"
10+
11+
$allUsers = GetAllGitHubUsers `
12+
-TenantId $TenantId `
13+
-ClientId $ClientId `
14+
-ClientSecret $ClientSecret
15+
16+
if (!$allUsers) {
17+
Write-Host "Failed to get all GitHub users"
18+
return $Fallback
19+
}
20+
21+
$targetUser = $allUsers.Where({ $_.aad.userPrincipalName -eq $EmailAddress -and $_.github.login }, 'First')
22+
23+
if (!$targetUser) {
24+
Write-Host "Failed to find GitHub user for $EmailAddress"
25+
return $Fallback
26+
}
27+
28+
return "@$($targetUser.github.login)"

0 commit comments

Comments
 (0)