Repository navigation
Replace user-based authentication with a GitHub App for release-related logic #79912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c38a9a6
d1a1b95
ebdae40
222e23f
0e0fe3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,8 +56,7 @@ jobs: | |
| bump-version: | ||
| name: Bump version | ||
| runs-on: 'ubuntu-24.04' | ||
| permissions: | ||
| contents: write | ||
| environment: 'GitHub Releases' | ||
| needs: compute-stable-branches | ||
| if: | | ||
| github.event_name == 'workflow_dispatch' && ( | ||
|
|
@@ -80,10 +79,18 @@ jobs: | |
| trunk_commit: ${{ steps.commit_version_bump_to_trunk.outputs.version_bump_commit }} | ||
|
|
||
| steps: | ||
| - name: Generate application token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| client-id: ${{ vars.APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
Copilot marked this conversation as resolved.
|
||
| permission-contents: write | ||
|
desrosj marked this conversation as resolved.
|
||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| token: ${{ secrets.GUTENBERG_TOKEN }} | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
| persist-credentials: true | ||
|
|
||
|
|
@@ -345,20 +352,27 @@ jobs: | |
| name: Revert version bump if build failed | ||
| needs: [bump-version, build] | ||
| runs-on: 'ubuntu-24.04' | ||
| permissions: | ||
| contents: write | ||
| environment: 'GitHub Releases' | ||
| if: | | ||
| always() && | ||
| needs.build.result == 'failure' && | ||
| needs.bump-version.outputs.release_branch_commit | ||
|
|
||
| steps: | ||
| - name: Generate application token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| client-id: ${{ vars.APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
Copilot marked this conversation as resolved.
|
||
| permission-contents: write | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| fetch-depth: 2 | ||
| ref: ${{ needs.bump-version.outputs.release_branch }} | ||
| token: ${{ secrets.GUTENBERG_TOKEN }} | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
| persist-credentials: true | ||
|
|
||
|
|
@@ -401,10 +415,18 @@ jobs: | |
| name: Create Release Draft and Attach Asset | ||
| needs: [bump-version, build] | ||
| runs-on: 'ubuntu-24.04' | ||
| permissions: | ||
| contents: write | ||
| environment: 'GitHub Releases' | ||
|
desrosj marked this conversation as resolved.
|
||
|
|
||
| steps: | ||
| - name: Generate application token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| client-id: ${{ vars.APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
Copilot marked this conversation as resolved.
|
||
| permission-contents: write | ||
| permission-workflows: write | ||
|
Comment on lines
+421
to
+428
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flagged by an AI agent while reviewing [major] This still validates the critical The PR moves release creation to a GitHub App token, which is the right credential direction. But the only step that requests Suggested shapeOne option is to add a preflight step at the start of - name: Verify release application token permissions
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write
permission-workflows: writeThen keep the existing contents-only token for checkout/push. That catches the permission/configuration failure before the workflow changes
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a false positive. The exact step where the original problem was encountered was the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, and I agree the earlier jobs don’t need If the App configuration is confirmed and expected to be stable, I’m fine treating this as an acceptable risk for this PR. The preflight suggestion was meant as a guardrail against App/environment misconfiguration, not because the earlier git-push steps themselves require |
||
|
|
||
| - name: Set Release Version | ||
| id: get_release_version | ||
| env: | ||
|
|
@@ -433,7 +455,7 @@ jobs: | |
| RELEASE_NAME: ${{ steps.get_release_version.outputs.version }} | ||
| VERSION: ${{ needs.bump-version.outputs.new_version }} | ||
| with: | ||
| github-token: ${{ secrets.GUTENBERG_TOKEN }} | ||
| github-token: ${{ steps.app-token.outputs.token }} | ||
| script: | | ||
| const fs = require('fs'); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if we found a way not to duplicate this step, but it's not possible when generating a token, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 steps generating a token, but only 2 are identical (only one grants
permission-workflows: writecapabilities).While it would be nice to eliminate the similar steps, from a security perspective it's preferable to create a separate token whenever possible to guarantee the principle of least privilege is followed and tokens are properly scoped per-job.