PYTHON-6076 Request workflows permission in create-release-branch - #3039
Conversation
fb69abf to
1a9d3d6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The workflow currently risks leaking the derived Authorization header (and potentially the token) to logs due to bash -x, and it also deviates from the repo’s pinned actions/checkout versioning convention.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Create Release Branch GitHub Actions workflow so the workflow can successfully push a branch even when the preparatory commit modifies workflow files (requiring workflows: write on the pushing token).
Changes:
- Replace
secure-checkout@v3withactions/create-github-app-token@v3to mint a GitHub App installation token that includesworkflows: write. - Add an explicit
actions/checkoutstep (withpersist-credentials: false) and configure git push authentication viaGH_TOKEN.
File summaries
| File | Description |
|---|---|
.github/workflows/create-release-branch.yml |
Switch to an App installation token with workflows permission; adjust checkout and git auth to enable pushing changes that touch workflow files. |
Review details
Suppressed comments (1)
.github/workflows/create-release-branch.yml:57
- This command computes a base64-encoded Authorization header containing the App token; with the job default
shell: bash -eux {0}, xtrace will log the fully-expanded header (including the base64 token) to the workflow logs. Disable-xfor this step and build the header without echoing it.
- name: Configure git auth for push
run: |
git config --local http.https://github.com/.extraheader \
"AUTHORIZATION: basic $(printf '%s' "x-access-token:${GH_TOKEN}" | base64 -w0)"
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1a9d3d6 to
42918b5
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new git auth step currently contains a shell-quoting bug that will break the workflow when configuring the push authorization header.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
42918b5 to
23fd08d
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The workflow change is narrowly scoped to fixing GH013 by requesting the correct token permissions and explicitly configuring push authentication.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
| ref: ${{ github.ref }} | ||
| token: ${{ env.GH_TOKEN }} | ||
| fetch-depth: 1 | ||
| persist-credentials: false |
There was a problem hiding this comment.
I think we can drop persist-credentials: false and Configure git auth for push because actions/checkout already writes the auth header so we don't need to not-save it and then re-create it.
There was a problem hiding this comment.
We don't want the auth stored on disk
PYTHON-6076
Changes in this PR
The Create Release Branch workflow fails at the push step because the
Prep branchcommit edits.github/workflows/release-python.yml, and the App token minted bysecure-checkout@v3does not requestworkflowspermission. GitHub rejects the push with GH013.secure-checkout@v3withactions/create-github-app-token@v3, requestingworkflows: writein addition tocontentsandpull-requests.actions/checkout@v7withpersist-credentials: false.GH_TOKEN.setup@v3only setsuser.name/user.email, and the third-partybump-versionpush step depends on checkout-configured credentials.Test Plan
Rerun the Create Release Branch workflow with
branch_name=v4.18,version=4.18.1.dev0,base_ref=mainand confirm thev4.18branch is created and pushed. Validated locally by pre-commit's "Validate GitHub Workflows" hook.Checklist
Checklist for Author
Checklist for Reviewer