ci: replace expiring GPR_ACCESS_TOKEN PAT with GITHUB_TOKEN - #1449
Jayanth Reddy Bujula (jbujula) wants to merge 3 commits into
Conversation
The GPR_ACCESS_TOKEN secret is a PAT that expires roughly weekly. Every time it lapses, all CI fails with a 401 restoring @microsoft/powerplatform-cli-wrapper from GitHub Packages, and someone has to rotate it by hand. GITHUB_TOKEN is minted per workflow run and expires with it, so there is nothing to rotate and no long-lived credential stored in the repo. Requires a one-time admin action first: grant this repository read access to the @microsoft/powerplatform-cli-wrapper package under the package's 'Manage Actions access' settings. Until that is done this will 401. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ac571cd-d84e-4b40-805a-e316a62ed292
CI result confirms the diagnosis - only the access grant is missingThe failure mode changed, which is the useful part:
401 -> 403 means So the remaining work is the single admin action in the description:
Once that is applied, re-run these checks - no code change should be needed. If they go green, |
This PR claimed to remove the expiring PAT but only covered two of the three workflows that use it. dependency-security.yml, added later by #1441, was still on GPR_ACCESS_TOKEN: .github/workflows/PullRequest.yml:45 (covered) .github/workflows/codeql.yml:59 (covered) .github/workflows/dependency-security.yml:43 (missed) That gap is a trap rather than a cosmetic omission: merging this PR and then deleting the GPR_ACCESS_TOKEN secret -- the whole point of the change -- would have silently broken the weekly dependency refresh the next Monday, and only that job would fail. Applies the same treatment as the other two: job-level `packages: read` plus GITHUB_TOKEN. `grep GPR_ACCESS_TOKEN .github/workflows/*.yml` is now empty, so the secret can be deleted safely once this lands. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ac571cd-d84e-4b40-805a-e316a62ed292
|
Pushed I originally scoped this to the two workflows I knew about. But three workflows on The third arrived later, in #1441, after this PR was opened. Why that matteredThe point of this PR is to let I had deliberately left ChangeSame treatment as the other two - job-level Verification
Still gated on the package grantI re-ran CI today after updating this branch. It still fails with: That remains the expected result and is still the useful signal: 403, not 401.
Once that is applied, re-run these checks; they should go green and this can merge. Order matters: merge this before deleting the secret, not after. |
Summary
Do not merge until the one-time admin step below is done - this will 401 otherwise.
GPR_ACCESS_TOKENis a PAT that expires roughly weekly. Each time it lapses, all CI fails restoring@microsoft/powerplatform-cli-wrapperfrom GitHub Packages:It has bitten twice in the last week alone, and is currently red on #1441. The secret was last updated
2026-08-06, consistent with a 7-day expiry.GITHUB_TOKENis minted per workflow run and expires with it - nothing to rotate, and no long-lived credential stored in the repo.Changes
PullRequest.ymlsecrets.GPR_ACCESS_TOKEN->secrets.GITHUB_TOKEN; addpermissions: contents: read+packages: readcodeql.ymlpackages: readto the existing permissions blockAdding an explicit
permissions:block toPullRequest.ymlalso drops it from the default (often write-all) token down to least privilege.Required one-time admin step
GITHUB_TOKENis scoped to this repo, so the package must grant it read access:microsoft/powerplatform-build-toolswith the Read roleThis is the mechanism GitHub documents for consuming a package from a different repository. The publishing side already uses
GITHUB_TOKEN(see the wrapper'sPublish.yml, which runs withpermissions: packages: write), so no PAT is involved there either - this just brings the consuming side in line.Verification
PullRequest.yml->{"contents":"read","packages":"read"}codeql.yml->{"actions":"read","contents":"read","security-events":"write","packages":"read"}GITHUB_TOKENcan restore the package and the PAT is genuinely redundant. If it 401s, the access grant above has not been applied yet - that is expected, not a code problem.Not covered by this PR
dependency-security.yml(in chore: automate dependency security fixes #1441) uses the same PAT. I will apply the identical change there once this approach is confirmed working, to avoid churning that PR twice..azure-pipelines/OfficialBuild.yml) authenticates separately via thegithub.com_npm_tehcrashxorservice connection. That is a second credential for the same purpose, named after an individual - worth revisiting separately for bus-factor reasons, but out of scope here.