From 78cb6c2382261e806946be62ce193d6399ba498a Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 26 May 2026 18:59:44 -0700 Subject: [PATCH 1/2] Switch to using GitHubApp --- eng/pipelines/build.yml | 12 ++++++++++-- eng/pipelines/sdk-update.yml | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/build.yml b/eng/pipelines/build.yml index 9091c51ad0d..91d61cb768c 100644 --- a/eng/pipelines/build.yml +++ b/eng/pipelines/build.yml @@ -95,12 +95,16 @@ extends: command: custom customCommand: run build workingDir: $(Build.SourcesDirectory)/autorest.csharp/src/TypeSpec.Extension/Emitter.Csharp + - template: /eng/common/pipelines/templates/steps/login-to-github.yml + parameters: + TokenOwners: + - Azure - ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}: - pwsh: > ./eng/PublishRelease.ps1 -AutorestArtifactDirectory ./artifacts/bin/AutoRest.CSharp/Release/net9.0/ -TypeSpecEmitterDirectory ./src/TypeSpec.Extension/Emitter.Csharp - -GitHubToken $(azuresdk-github-pat) + -GitHubToken $(GH_TOKEN) -NpmToken $(azure-sdk-npm-token) -BuildNumber $(Build.BuildNumber) -Sha $(Build.SourceVersion) @@ -249,6 +253,10 @@ extends: Write-Host "Setting variable PrTitle to '$prTitle'" Write-Host "##vso[task.setvariable variable=PrTitle]$prTitle" displayName: 'Build PR Title' + - template: /eng/common/pipelines/templates/steps/login-to-github.yml + parameters: + TokenOwners: + - Azure - task: PowerShell@2 displayName: Create pull request inputs: @@ -260,6 +268,6 @@ extends: -BaseBranch "main" -PROwner "azure-sdk" -PRBranch $(BranchName) - -AuthToken "$(azuresdk-github-pat)" + -AuthToken "$(GH_TOKEN)" -PRTitle "$(PrTitle)" -PRBody "Update AutoRest C# version to $(AutorestCSharpVersion)" diff --git a/eng/pipelines/sdk-update.yml b/eng/pipelines/sdk-update.yml index 2b9fddea118..37785ddc38a 100644 --- a/eng/pipelines/sdk-update.yml +++ b/eng/pipelines/sdk-update.yml @@ -214,6 +214,7 @@ extends: Write-Host "Setting variable PrTitle to '$prTitle'" Write-Host "##vso[task.setvariable variable=PrTitle]$prTitle" displayName: 'Build PR Title' + - template: /eng/common/pipelines/templates/steps/login-to-github.yml - task: PowerShell@2 displayName: Create pull request inputs: @@ -225,7 +226,7 @@ extends: -BaseBranch "main" -PROwner "azure-sdk" -PRBranch "$(BranchName)" - -AuthToken "$(azuresdk-github-pat)" + -AuthToken "$(GH_TOKEN)" -PRTitle "$(PrTitle)" -PRBody "Triggered from $(PRUrl.PRUrl)" -OpenAsDraft $true From 59761726e3ff851e165c3c55b22555b14683c856 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Mon, 15 Jun 2026 14:20:50 -0700 Subject: [PATCH 2/2] Add login-to-github.yml script --- .../templates/steps/login-to-github.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 eng/common/pipelines/templates/steps/login-to-github.yml diff --git a/eng/common/pipelines/templates/steps/login-to-github.yml b/eng/common/pipelines/templates/steps/login-to-github.yml new file mode 100644 index 00000000000..a3ccf2cecea --- /dev/null +++ b/eng/common/pipelines/templates/steps/login-to-github.yml @@ -0,0 +1,29 @@ +# Will output a variable named GH_TOKEN_ for each owner in TokenOwners if there is only one owner it will just output GH_TOKEN + +parameters: +- name: TokenOwners + type: object + default: + - Azure +- name: VariableNamePrefix + type: string + default: GH_TOKEN +- name: ExportAsOutputVariable + type: boolean + default: false +- name: ScriptDirectory + default: eng/common/scripts + +steps: +- task: AzureCLI@2 + name: GenerateGitHubToken + displayName: "Login to GitHub" + inputs: + azureSubscription: 'AzureSDKEngKeyVault Secrets' + scriptType: pscore + scriptLocation: scriptPath + scriptPath: ${{ parameters.ScriptDirectory }}/login-to-github.ps1 + arguments: > + -InstallationTokenOwners '${{ join(''',''', parameters.TokenOwners) }}' + -VariableNamePrefix '${{ parameters.VariableNamePrefix }}' + -ExportAsOutputVariable:$${{ parameters.ExportAsOutputVariable }} \ No newline at end of file