Skip to content

Commit b43fcb2

Browse files
committed
ci: harden the release-PR workflow auth
Checkout now runs read-only with persist-credentials: false so the token isn't left in the git config for the whole job, and the write-capable app token is only used at the push step (via the push URL, not persisted). The job also drops its blanket contents/pull-requests write permissions, since the default token only needs read and the app token does the writing. Addresses the review on this PR and clears zizmor's artipacked finding for this workflow. Note: AI-assisted (Claude Code), verified with zizmor that the artipacked finding on this file is gone after the change.
1 parent 374e7c6 commit b43fcb2

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

.github/workflows/releasepr.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ permissions:
99
jobs:
1010
createPR:
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
14-
pull-requests: write
1512
steps:
1613
- name: Checkout
1714
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1815
with:
19-
token: ${{ secrets.JLAB_APP_TOKEN }}
16+
# Read-only checkout: the default token is never persisted into the git
17+
# config. The write-capable app token is only introduced at the push
18+
# step below.
19+
persist-credentials: false
2020

2121
- name: Get package info
2222
shell: bash
@@ -43,9 +43,11 @@ jobs:
4343
if: steps.pre-release-exists.outputs.result == 'true'
4444
env:
4545
APP_VERSION: ${{ steps.package-info.outputs.version }}
46-
GITHUB_TOKEN: ${{ secrets.JLAB_APP_TOKEN }}
46+
GH_TOKEN: ${{ secrets.JLAB_APP_TOKEN }}
4747
run: |
48-
set -eux
48+
# No -x: the push URL carries the token, so keep it out of the log
49+
# (GitHub also masks the secret, this is belt and suspenders).
50+
set -eu
4951
# git checkout -b fails if the branch already exists, which keeps a
5052
# re-run from opening a duplicate release PR.
5153
BRANCH_NAME="release-v${APP_VERSION}"
@@ -56,8 +58,13 @@ jobs:
5658
date +%s > auto-release.log
5759
git add auto-release.log
5860
git commit -m "Update auto-release logs"
59-
git push --set-upstream origin "${BRANCH_NAME}"
61+
# Checkout persisted no credentials, so authenticate this one push with
62+
# the app token instead of keeping it in the git config all job long.
63+
git push \
64+
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
65+
"HEAD:refs/heads/${BRANCH_NAME}"
6066
6167
gh pr create \
68+
--head "${BRANCH_NAME}" \
6269
--title "Release v${APP_VERSION}" \
6370
--body "Release v${APP_VERSION}"

0 commit comments

Comments
 (0)