Skip to content

Add PATs rotation to agentic workflow(s)#13496

Merged
JanKrivanek merged 4 commits intomainfrom
dev/jankrivanek/add-pats-rotation
Apr 8, 2026
Merged

Add PATs rotation to agentic workflow(s)#13496
JanKrivanek merged 4 commits intomainfrom
dev/jankrivanek/add-pats-rotation

Conversation

@JanKrivanek
Copy link
Copy Markdown
Member

@JanKrivanek JanKrivanek commented Apr 7, 2026

Context

Using a single PAT shared across all agentic workflows can lead to rate-limiting. This PR introduces a PAT-rotation mechanism to randomly select from a pool of Copilot PAT secrets.

Changes Made

  • Recompiled the agentic workflows with gh-aw v0.67.1 (cron schedule time may differ as a side effect of recompilation)
  • Copied the relevant reusable files from https://github.com/dotnet/skills/tree/main/.github/actions/select-copilot-pat
  • Added the PATs rotation to our agentic workflow(s) using the COPILOT_GITHUB_TOKEN / COPILOT_GITHUB_TOKEN_1..9 naming convention
  • Updated README.md in .github/actions/select-copilot-pat to document the COPILOT_GITHUB_TOKEN(_#) naming convention used in this repo (replacing the generic COPILOT_PAT_# placeholder examples)

Testing

  • Verified that the compiled workflow correctly references COPILOT_GITHUB_TOKEN and COPILOT_GITHUB_TOKEN_1 through COPILOT_GITHUB_TOKEN_9 in both the select-copilot-pat step env bindings and the case(...) expression

Notes

The PAT pool uses COPILOT_GITHUB_TOKEN as the base secret (index 0) and COPILOT_GITHUB_TOKEN_1 through COPILOT_GITHUB_TOKEN_9 for additional pool entries. This is a stop-gap workaround until organization/enterprise billing is offered for agentic workflows.

Regenerate lock files with the new compiler version.
No functional changes.
Copy the select-copilot-pat composite action from dotnet/skills.
This selects a random Copilot PAT from a numbered pool of secrets
to distribute API load across multiple PATs.

This is a stop-gap until organization-level billing is available
for Agentic Workflows. See .github/actions/select-copilot-pat/README.md.
Use the select-copilot-pat action to randomly select from a pool of
COPILOT_GITHUB_TOKEN / COPILOT_GITHUB_TOKEN_1..9 secrets, distributing
Copilot API load across multiple PATs.

Currently only COPILOT_GITHUB_TOKEN is configured; additional secrets
can be added as COPILOT_GITHUB_TOKEN_1 through COPILOT_GITHUB_TOKEN_9.
@JanKrivanek JanKrivanek requested a review from a team as a code owner April 7, 2026 10:38
Copilot AI review requested due to automatic review settings April 7, 2026 10:38
@JanKrivanek JanKrivanek enabled auto-merge April 7, 2026 10:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 repository’s agentic “Close Stale Pull Requests” workflow by recompiling it with gh-aw v0.67.1 and introducing a PAT-rotation mechanism (randomly selecting from a pool of Copilot PAT secrets) via a new reusable composite action.

Changes:

  • Add a reusable composite action (.github/actions/select-copilot-pat) to randomly select a Copilot PAT from a secret pool.
  • Wire the selected PAT into the agentic workflow via pre_activation outputs + an engine.env case(...) override of COPILOT_GITHUB_TOKEN.
  • Recompile the generated workflow lock file with gh-aw v0.67.1 (large regenerated diff).
Show a summary per file
File Description
.github/workflows/close-stale-prs.agent.md Adds pre-activation steps and engine env override to rotate Copilot PAT usage.
.github/workflows/close-stale-prs.agent.lock.yml Regenerated compiled workflow output (includes PAT selection wiring and other compiler-output changes).
.github/aw/actions-lock.json Adds github/gh-aw-actions/setup@v0.67.1 pin for the new compiler version.
.github/actions/select-copilot-pat/README.md Documents how to onboard and configure the PAT pool + workflow wiring.
.github/actions/select-copilot-pat/action.yml Implements the composite action that selects a non-empty secret index (0–9) and outputs it.

Copilot's findings

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

…stead of COPILOT_PAT_#

Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/7cf4fd9a-e8bf-43c6-bd2e-9278df2c8be3

Co-authored-by: JanKrivanek <3809076+JanKrivanek@users.noreply.github.com>
auto-merge was automatically disabled April 7, 2026 10:47

Head branch was pushed to by a user without write access

@JanKrivanek JanKrivanek enabled auto-merge April 7, 2026 11:00
@JanKrivanek
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JanKrivanek JanKrivanek merged commit c76c3f7 into main Apr 8, 2026
10 checks passed
@JanKrivanek JanKrivanek deleted the dev/jankrivanek/add-pats-rotation branch April 8, 2026 09:41
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.

4 participants