Skip to content

fix(closed): grant pull-requests write to CommentSubPRs job [FTTECH-10130]#153

Open
florentsorel wants to merge 2 commits into
masterfrom
fix/closed-housekeeping-pr-permissions
Open

fix(closed): grant pull-requests write to CommentSubPRs job [FTTECH-10130]#153
florentsorel wants to merge 2 commits into
masterfrom
fix/closed-housekeeping-pr-permissions

Conversation

@florentsorel

Copy link
Copy Markdown
Contributor

Problème

Le job Comment rebase --onto on Sub PRs du snippet closed.yml (action after-pr-merged) échoue sur chaque PR mergée, dans tous les repos qui consomment ce snippet (constaté sur panoramai : 100 % des PR mergées en rouge sur le check « Closed PR Housekeeping »).

RequestError [HttpError]: Resource not accessible by integration   (403)
  GET /repos/<org>/<repo>/pulls/<n>
  at sendRebaseOntoCommentOnSubbranches (lib/actions/pullRequestMerged.js:14)

Le job n'a aucun bloc permissions:. Quand la permission par défaut du GITHUB_TOKEN est rabotée au niveau org/repo, le token n'a pas le scope pull-requests, donc le tout premier appel (pulls.get) renvoie 403 avant même d'arriver à pulls.list / issues.createComment.

Impact : CI rouge cosmétique post-merge (ne bloque aucune PR) + le commentaire « 👉 rebase --onto » n'est jamais posté sur les sous-PR empilées.

Fix

On déclare explicitement les scopes minimaux dont l'action a besoin sur ce job :

  • pull-requests: writepulls.get, pulls.list, et création/maj du commentaire sur les sous-PR (les sous-PR sont des PR, donc le scope pull-requests couvre l'endpoint issues/comments).
  • contents: read.

Indépendant de la permission par défaut de l'org (un bloc permissions: explicite l'emporte sur le défaut restrictif).

Distribution

sample/workflows/closed.yml est la source canonique référencée par github-mobsuccess-policy (app/policies/gh-actions.js → action closed). Une fois mergé, mobsuccessbot re-sync le snippet wrappé dans tous les repos.

🤖 Generated with Claude Code

Le job « Comment rebase --onto on Sub PRs » (action after-pr-merged) tourne
sans bloc permissions:. Quand le GITHUB_TOKEN par defaut est rabote au niveau
org, le tout premier appel (pulls.get) renvoie 403 « Resource not accessible
by integration » et le job echoue sur chaque PR mergee — CI rouge cosmetique
post-merge + le memo « rebase --onto » n'est jamais poste sur les sous-PR.

On accorde explicitement les scopes minimaux dont l'action a besoin :
pull-requests:write (pulls.get/list + creation/maj du commentaire sur les
sous-PR) et contents:read. Independant de la permission par defaut de l'org.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 19, 2026 07:14
@github-actions github-actions Bot added the fix Bug Fix label Jun 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the canonical closed.yml workflow snippet (used by the after-pr-merged action) to explicitly grant the GITHUB_TOKEN the permissions needed by the CommentSubPRs job, preventing 403 Resource not accessible by integration failures in repos with restricted default token permissions.

Changes:

  • Add an explicit permissions: block to the CommentSubPRs job in sample/workflows/closed.yml.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sample/workflows/closed.yml Outdated
@florentsorel florentsorel changed the title fix(closed): grant pull-requests write to CommentSubPRs job fix(closed): grant pull-requests write to CommentSubPRs job [FTTECH-10130] Jun 19, 2026
@florentsorel florentsorel self-assigned this Jun 19, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants