Use github app instead of pat for loc pipeline - #9650
Open
dibarbet wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 thanGitHubPAT. - 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}.`); |
Member
There was a problem hiding this comment.
Could we sanitize the output for known PAT formats?
Contributor
There was a problem hiding this comment.
Copilot's findings
Suppressed comments (1)
tasks/localization/publishLocalizationContent.ts:84
- The
git ls-remotebranch-existence check is usingrefs/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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes taken from https://github.com/dotnet/arcade/pull/17219/changes
Passing run #9649