Skip to content

Use github app instead of pat for loc pipeline - #9650

Open
dibarbet wants to merge 8 commits into
dotnet:mainfrom
dibarbet:dev/dabarbet/loc-app
Open

Use github app instead of pat for loc pipeline#9650
dibarbet wants to merge 8 commits into
dotnet:mainfrom
dibarbet:dev/dabarbet/loc-app

Conversation

@dibarbet

@dibarbet dibarbet commented Aug 6, 2026

Copy link
Copy Markdown
Member

Copilot AI review requested due to automatic review settings August 6, 2026 18:06
@dibarbet
dibarbet requested a review from a team as a code owner August 6, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the localization publishing pipeline to authenticate to GitHub using a GitHub App installation token (instead of a PAT), aligning with improved credential management for automation.

Changes:

  • Switch localization publishing to use a GitHubToken (GitHub App installation token) rather than GitHubPAT.
  • Update localization publish logic to diff only staged localization files and improve git error reporting.
  • Add an Azure Pipelines step to mint a GitHub App installation token via Key Vault and GitHub’s App APIs.
Show a summary per file
File Description
tasks/localization/publishLocalizationContent.ts Uses --cached diff for staged localization files, switches auth from PAT to token, and improves git execution error handling.
package.nls.json Fixes a typo in a configuration description string (“Specifes” → “Specifies”).
azure-pipelines/loc.yml Replaces PAT usage with an AzureCLI step that retrieves a GitHub App installation token and passes it to the publish step.
azure-pipelines/Get-GitHubAppToken.ps1 New script to sign a GitHub App JWT via Key Vault, locate the installation, and create an installation access token for the pipeline.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment on lines +59 to 62
const token = process.env['GitHubToken'];
if (!token) {
throw 'No GitHub token found.';
}
Comment on lines +149 to +161
const command = printCommand ? `git ${args.join(' ')}` : 'git command';
if (result.error) {
throw new Error(`Failed to start ${command}: ${result.error.message}`);
}
if (result.status != 0) {
const output = [result.stderr, result.stdout]
.map((value) => value.trim())
.filter((value) => value.length > 0)
.join(EOL);
if (printCommand) {
console.log(`Failed to execute git ${args.join(' ')}.`);
console.error(`Failed to execute ${command}.`);
}
throw err;
throw new Error(output || `${command} failed with code ${result.status}.`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we sanitize the output for known PAT formats?

Copilot AI review requested due to automatic review settings August 6, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Suppressed comments (1)

tasks/localization/publishLocalizationContent.ts:84

  • The git ls-remote branch-existence check is using refs/head/…, which does not match the standard branch ref namespace (refs/heads/…). As a result, this check will always come back empty and the script may attempt to push even when the branch already exists.
    const lsRemote = await git(['ls-remote', remoteRepoAlias, 'refs/head/' + newBranchName], {
        sensitiveValues: [token],
    });
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants