From 3442d702c5a2c844f370a1dd8fe5352917a22833 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 4 Aug 2026 15:06:00 -0700 Subject: [PATCH] Expand eng common sync to support microsoft org --- eng/common/pipelines/templates/steps/login-to-github.yml | 4 ++++ eng/common/scripts/login-to-github.ps1 | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/login-to-github.yml b/eng/common/pipelines/templates/steps/login-to-github.yml index 91327fcbb123..22c1464cb28d 100644 --- a/eng/common/pipelines/templates/steps/login-to-github.yml +++ b/eng/common/pipelines/templates/steps/login-to-github.yml @@ -8,6 +8,9 @@ parameters: - name: VariableNamePrefix type: string default: GH_TOKEN +- name: AlwaysUseOwnerSuffix + type: boolean + default: false - name: ExportAsOutputVariable type: boolean default: false @@ -25,4 +28,5 @@ steps: arguments: > -InstallationTokenOwners '${{ join(''',''', parameters.TokenOwners) }}' -VariableNamePrefix '${{ parameters.VariableNamePrefix }}' + -AlwaysUseOwnerSuffix:$${{ parameters.AlwaysUseOwnerSuffix }} -ExportAsOutputVariable:$${{ parameters.ExportAsOutputVariable }} \ No newline at end of file diff --git a/eng/common/scripts/login-to-github.ps1 b/eng/common/scripts/login-to-github.ps1 index c0b050f27353..c3553b91a208 100644 --- a/eng/common/scripts/login-to-github.ps1 +++ b/eng/common/scripts/login-to-github.ps1 @@ -22,6 +22,9 @@ Prefix for the exported variable name (default: GH_TOKEN). With a single owner, exports as GH_TOKEN. With multiple owners, exports as GH_TOKEN_. +.PARAMETER AlwaysUseOwnerSuffix + Export tokens as _ even when only one owner is requested. + .PARAMETER ExportAsOutputVariable When set in Azure DevOps, also exports the variable as an output variable (##vso[task.setvariable ...;isOutput=true]) for downstream jobs/stages. @@ -39,6 +42,7 @@ param( [string] $GitHubAppId = '1086291', # Azure SDK Automation App ID [string[]] $InstallationTokenOwners = @("Azure"), [string] $VariableNamePrefix = "GH_TOKEN", + [switch] $AlwaysUseOwnerSuffix, [switch] $ExportAsOutputVariable ) @@ -231,7 +235,7 @@ function Invoke-LoginToGitHub { $installationToken = New-GitHubInstallationToken -Jwt $jwt -InstallationId $installationId -ApiBase $GitHubApiBaseUrl -ApiVersion $GitHubApiVersion $variableName = $VariableNamePrefix - if ($InstallationTokenOwners.Count -gt 1) { + if ($AlwaysUseOwnerSuffix -or $InstallationTokenOwners.Count -gt 1) { $variableName = $VariableNamePrefix + "_" + $normalizedOwner }