CI:: declare explicit permissions for stale and weekly cron workflows#33902
Conversation
📝 WalkthroughWalkthroughThis PR adds permission blocks to two GitHub Actions workflows to enable specific access levels: markdown link checks in the cron-weekly workflow, and issue/pull-request management in the stale workflow. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/stale.yml (1)
6-8: Permission block is correct and sufficient foractions/stale.
issues: writecovers stale label operations, comments, and closing on issues;pull-requests: writecovers stale label operations and comments on PRs; both are needed forremove-stale-when-updated(defaulttrue), which removes the stale label from both issues and PRs. Note that even when only processing stale PRs,issues: writeis also required — which is satisfied here.As a minor hardening note, GitHub's own documentation example for
actions/stalespecifically shows permissions scoped at the job level rather than the workflow level. For this single-job workflow it's functionally equivalent, but job-level scoping is the idiomatic preference.♻️ Optional: scope permissions to the job level
-permissions: - issues: write # to close and label issues (actions/stale) - pull-requests: write # to mark stale pull requests (actions/stale) - jobs: stale: runs-on: ubuntu-latest if: github.repository_owner == 'storybookjs' + permissions: + issues: write # to close and label issues (actions/stale) + pull-requests: write # to mark stale pull requests (actions/stale) steps:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/stale.yml around lines 6 - 8, The permissions block is currently defined at the workflow level (permissions: with issues: write and pull-requests: write) which is functionally correct but the reviewer recommends scoping to the job level; update the workflow to move the permissions block from the top-level to the single job that runs the actions/stale step (retain issues: write and pull-requests: write and keep remove-stale-when-updated behavior unchanged), i.e., locate the job that invokes actions/stale and add the permissions: { issues: write, pull-requests: write } under that job so permissions are idiomatically scoped to the job.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/stale.yml:
- Around line 6-8: The permissions block is currently defined at the workflow
level (permissions: with issues: write and pull-requests: write) which is
functionally correct but the reviewer recommends scoping to the job level;
update the workflow to move the permissions block from the top-level to the
single job that runs the actions/stale step (retain issues: write and
pull-requests: write and keep remove-stale-when-updated behavior unchanged),
i.e., locate the job that invokes actions/stale and add the permissions: {
issues: write, pull-requests: write } under that job so permissions are
idiomatically scoped to the job.
Summary
permissionsto.github/workflows/stale.ymlpermissionsto.github/workflows/cron-weekly.ymlWhy
Both workflows previously relied on implicit token defaults. Declaring explicit scopes makes required access clear and keeps token privileges least-privilege:
stale.yml:issues: write,pull-requests: writeforactions/stalecron-weekly.yml:contents: readfor repository checkout during markdown link checksValidation
Summary by CodeRabbit