@@ -50,15 +50,26 @@ jobs:
5050 runs-on : ubuntu-latest
5151 timeout-minutes : 10
5252 steps :
53+ # Prefer a short-lived, repo-scoped GitHub App installation token over a
54+ # personal PAT. Gated on the repo variable so an unconfigured app simply
55+ # falls through to the existing chain instead of breaking the release.
56+ - name : Mint installation token
57+ id : app-token
58+ if : ${{ vars.RELEASE_APP_ID != '' }}
59+ continue-on-error : true
60+ uses : actions/create-github-app-token@v3
61+ with :
62+ app-id : ${{ vars.RELEASE_APP_ID }}
63+ private-key : ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
64+
5365 - uses : actions/checkout@v7
5466 with :
5567 ref : ${{ github.ref_name }}
56- # PAT (not GITHUB_TOKEN) for the same reason release-please.yml uses one:
57- # a push made with GITHUB_TOKEN does not trigger workflows, so the release
58- # PR's checks would never re-run against the synced commit and would stay
59- # red. Falls back to GITHUB_TOKEN, where the sync still lands and a manual
60- # re-run of the PR's checks picks it up.
61- token : ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
68+ # Do NOT persist the credential into .git/config. The next step runs
69+ # scripts/version-sync.py *from the checked-out branch*, and this job
70+ # triggers on a push to the unprotected glob release-please--branches--**.
71+ # A persisted token would be readable by that script.
72+ persist-credentials : false
6273
6374 - uses : actions/setup-python@v6
6475 with :
7283 run : python scripts/verify-versions.py
7384
7485 - name : Commit and push if anything changed
86+ env :
87+ # An app installation token if one was minted, else the existing
88+ # chain. A PAT (not GITHUB_TOKEN) is still preferred here for the same
89+ # reason release-please.yml wants one: a push made with GITHUB_TOKEN
90+ # does not trigger workflows, so the release PR's checks would never
91+ # re-run against the synced commit and would stay red. Supplied only
92+ # to this step, after the branch-supplied script has already run.
93+ SYNC_TOKEN : ${{ steps.app-token.outputs.token || secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
7594 run : |
7695 if git diff --quiet; then
7796 echo "Already in sync — nothing to commit."
@@ -81,7 +100,12 @@ jobs:
81100 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
82101 git add -A
83102 git commit -m "chore: sync generated version metadata"
103+ # Push via an explicit remote URL because the checkout no longer
104+ # persists credentials. Passed on stdin-free env expansion so the
105+ # token is not written to the command line or into .git/config.
84106 # This push re-triggers this workflow. version-sync.py is idempotent, so
85107 # the next run finds no diff and exits above without pushing — the loop
86108 # terminates after one no-op run.
87- git push origin HEAD:"${GITHUB_REF_NAME}"
109+ git push \
110+ "https://x-access-token:${SYNC_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
111+ HEAD:"${GITHUB_REF_NAME}"
0 commit comments