|
22 | 22 | Prefix for the exported variable name (default: GH_TOKEN). |
23 | 23 | With a single owner, exports as GH_TOKEN. With multiple owners, exports as GH_TOKEN_<Owner>. |
24 | 24 |
|
| 25 | +.PARAMETER ExportAsOutputVariable |
| 26 | + When set in Azure DevOps, also exports the variable as an output variable |
| 27 | + (##vso[task.setvariable ...;isOutput=true]) for downstream jobs/stages. |
| 28 | +
|
25 | 29 | .OUTPUTS |
26 | 30 | Sets environment variables in the current process and exports them to the CI system: |
27 | 31 | - Azure DevOps: sets secret pipeline variables via ##vso logging commands |
|
34 | 38 | [string] $KeyName = "azure-sdk-automation", |
35 | 39 | [string] $GitHubAppId = '1086291', # Azure SDK Automation App ID |
36 | 40 | [string[]] $InstallationTokenOwners = @("Azure"), |
37 | | - [string] $VariableNamePrefix = "GH_TOKEN" |
| 41 | + [string] $VariableNamePrefix = "GH_TOKEN", |
| 42 | + [switch] $ExportAsOutputVariable |
38 | 43 | ) |
39 | 44 |
|
40 | 45 | $ErrorActionPreference = 'Stop' |
@@ -239,6 +244,11 @@ function Invoke-LoginToGitHub { |
239 | 244 | if ($null -ne $env:SYSTEM_TEAMPROJECTID) { |
240 | 245 | Write-Host "##vso[task.setvariable variable=$variableName;issecret=true]$installationToken" |
241 | 246 | Write-Host "Azure DevOps variable '$variableName' has been set (secret)." |
| 247 | + |
| 248 | + if ($ExportAsOutputVariable) { |
| 249 | + Write-Host "##vso[task.setvariable variable=$variableName;issecret=true;isOutput=true]$installationToken" |
| 250 | + Write-Host "Azure DevOps output variable '$variableName' has been set (secret)." |
| 251 | + } |
242 | 252 | } |
243 | 253 |
|
244 | 254 | # GitHub Actions: mask the token and export to GITHUB_ENV |
|
0 commit comments