Skip to content

ci: authenticate weekly generation pipelines with GitHub App instead of PAT#3657

Open
ramsessanchez wants to merge 2 commits into
mainfrom
ci/github-app-auth
Open

ci: authenticate weekly generation pipelines with GitHub App instead of PAT#3657
ramsessanchez wants to merge 2 commits into
mainfrom
ci/github-app-auth

Conversation

@ramsessanchez

Copy link
Copy Markdown
Contributor

Summary

Moves the weekly generation pipelines off long-lived PAT authentication and onto a GitHub App installation token, mirroring the approach used by the MSGraph-SDK-Code-Generator generation pipelines.

Instead of git push/gh pr create using the PAT $(GITHUB_TOKEN), the pipelines now mint a short-lived (~1h) GitHub App installation token from Key Vault.

What changed

New files

  • scripts/Generate-Github-Token.ps1 — builds an RS256-signed JWT from the App client id + private key, resolves the installation id (org → repo → user), and exchanges it for a repository-scoped installation token.
  • .azure-pipelines/common-templates/get-github-app-token.yml — fetches microsoft-graph-devx-bot-appid / microsoft-graph-devx-bot-privatekey from akv-prod-eastus via the Federated AKV Managed Identity Connection, runs the script, masks the token, and exposes it to subsequent steps as GITHUB_TOKEN.

Wired in before every push / PR (existing $(GITHUB_TOKEN) references are unchanged and now resolve to the App token):

  • common-templates/create-pr.yml — covers the PR path for all three pipelines
  • common-templates/download-openapi-docs.yml — weekly-generation push
  • generation-templates/generate-command-metadata.yml — command-metadata-refresh push
  • weekly-examples-update.yml — inline examples push
  • command-metadata-refresh.yml — inline version-bump push

The token is generated immediately before each push to avoid the 1-hour expiry on long-running jobs.

Follow-ups

  • Once a green run confirms this works, the variable-group GITHUB_TOKEN PAT can be removed from the ADO library (portal change).
  • generation-templates/generate-helpdocs-template.yml also uses the PAT but is not referenced by any active pipeline, so it was left out of scope.

Notes

  • Assumes the Federated AKV Managed Identity Connection service connection is authorized in this ADO project (Key Vault already used by other repos).

Note: This pull request was created with assistance from GitHub Copilot.

…of PAT

Mint a short-lived GitHub App installation token from Key Vault (akv-prod-eastus
secrets microsoft-graph-devx-bot-appid / -privatekey via the "Federated AKV
Managed Identity Connection") and use it for git push and gh pr create,
replacing the PAT GITHUB_TOKEN in the weekly-generation, weekly-examples-update,
and command-metadata-refresh pipelines.

Adds scripts/Generate-Github-Token.ps1 and the reusable
common-templates/get-github-app-token.yml, inserted before every push/PR step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b1e4dbfd-ffcd-4a3e-bd35-1632b2912252
@ramsessanchez ramsessanchez requested a review from a team as a code owner July 10, 2026 22:16
adrian05-ms
adrian05-ms previously approved these changes Jul 10, 2026
This template is not referenced by any pipeline in this repo or in
MicrosoftDocs/microsoftgraph-docs-powershell, so it never runs. Removing it as
dead code (it also carried the last remaining PAT-based git push).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b1e4dbfd-ffcd-4a3e-bd35-1632b2912252
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