Skip to content

Commit ac41e01

Browse files
committed
fix(ci): scope BOT_TOKEN to the push step, don't persist in checkout
Per CodeRabbit: checkout with token + default persist-credentials left the admin PAT in .git/config for all later steps, including the repo-controlled 'make ... update' pipeline. Set persist-credentials: false and apply the PAT inline (never written to git config) only in the commit/push step.
1 parent 7626c5e commit ac41e01

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

.github/workflows/daily-update.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
# Pin to main so a workflow_dispatch from a feature branch can't
2525
# publish data based on non-main code (the commit still lands on main).
2626
ref: main
27-
# Persist a PAT (admin owner) instead of GITHUB_TOKEN so the later
28-
# push (a) bypasses the `main` ruleset via the Repository-admin bypass
29-
# actor, and (b) triggers deploy-pages — GITHUB_TOKEN pushes are
30-
# suppressed by GitHub's workflow-recursion guard, so the site would
31-
# otherwise never refresh after a data commit.
32-
token: ${{ secrets.BOT_TOKEN }}
27+
# Don't persist any token in .git/config: the pipeline step below runs
28+
# repo/third-party code, and the admin PAT must not be readable by it.
29+
# The PAT is applied inline only in the commit/push step.
30+
persist-credentials: false
3331
- uses: actions/setup-python@v6
3432
with:
3533
python-version: '3.12'
@@ -41,6 +39,8 @@ jobs:
4139
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4240
run: make -C tracks/${{ matrix.track }} update
4341
- name: Commit and push
42+
env:
43+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
4444
run: |
4545
git config user.name 'github-actions[bot]'
4646
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
@@ -50,8 +50,12 @@ jobs:
5050
exit 0
5151
fi
5252
git commit -m "chore(${{ matrix.track }}): daily update $(date -u +%Y-%m-%d)"
53+
# Inline auth (never written to .git/config) with an admin PAT that the
54+
# `main` ruleset bypasses; a PAT push also lets deploy-pages fire, which
55+
# GITHUB_TOKEN pushes can't (workflow-recursion guard).
56+
remote="https://x-access-token:${BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
5357
for i in 1 2 3 4 5; do
54-
if git pull --rebase origin main && git push origin HEAD:main; then
58+
if git pull --rebase "$remote" main && git push "$remote" HEAD:main; then
5559
exit 0
5660
fi
5761
sleep $((i * 5))

.github/workflows/weekly-digest.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
# Pin to main so a workflow_dispatch from a feature branch can't
2525
# publish a digest built from non-main code.
2626
ref: main
27-
# Persist a PAT (admin owner) instead of GITHUB_TOKEN so the later
28-
# push (a) bypasses the `main` ruleset via the Repository-admin bypass
29-
# actor, and (b) triggers deploy-pages — GITHUB_TOKEN pushes are
30-
# suppressed by GitHub's workflow-recursion guard, so the site would
31-
# otherwise never refresh after a digest commit.
32-
token: ${{ secrets.BOT_TOKEN }}
27+
# Don't persist any token in .git/config: the pipeline step below runs
28+
# repo/third-party code, and the admin PAT must not be readable by it.
29+
# The PAT is applied inline only in the commit/push step.
30+
persist-credentials: false
3331
- uses: actions/setup-python@v6
3432
with:
3533
python-version: '3.12'
@@ -41,6 +39,8 @@ jobs:
4139
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4240
run: make -C tracks/${{ matrix.track }} weekly
4341
- name: Commit and push
42+
env:
43+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
4444
run: |
4545
git config user.name 'github-actions[bot]'
4646
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
@@ -50,8 +50,12 @@ jobs:
5050
exit 0
5151
fi
5252
git commit -m "chore(${{ matrix.track }}): weekly digest $(date -u +%Y-W%V)"
53+
# Inline auth (never written to .git/config) with an admin PAT that the
54+
# `main` ruleset bypasses; a PAT push also lets deploy-pages fire, which
55+
# GITHUB_TOKEN pushes can't (workflow-recursion guard).
56+
remote="https://x-access-token:${BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
5357
for i in 1 2 3 4 5; do
54-
if git pull --rebase origin main && git push origin HEAD:main; then
58+
if git pull --rebase "$remote" main && git push "$remote" HEAD:main; then
5559
exit 0
5660
fi
5761
sleep $((i * 5))

0 commit comments

Comments
 (0)