Skip to content

ci(label-pr): run labeler with target context#1105

Closed
Will-hxw wants to merge 1 commit intomongodb-js:mainfrom
Will-hxw:codex/ci/fork-pr-labeler
Closed

ci(label-pr): run labeler with target context#1105
Will-hxw wants to merge 1 commit intomongodb-js:mainfrom
Will-hxw:codex/ci/fork-pr-labeler

Conversation

@Will-hxw
Copy link
Copy Markdown

Background

Fork PRs can trigger the current Label PR workflow with a read-only GITHUB_TOKEN. The label step then fails while calling gh pr edit --add-label, for example in #1097 with GraphQL: Resource not accessible by integration (addLabelsToLabelable).

What Changed

  • Run the label workflow on pull_request_target so it executes in the base repository context and can update PR labels for fork PRs.
  • Keep explicit least-privilege permissions, adding contents: read alongside the existing label-related write scopes.
  • Remove the checkout step because this workflow only reads PR metadata and edits labels.
  • Set GH_REPO explicitly so gh pr view/edit works without a checked-out repository.

Not Changed

  • The conventional commit prefix to label mapping is unchanged.
  • No project code, tests, dependencies, or build configuration are changed.

Risk

Low for this workflow because it does not checkout or execute pull request code. It only reads the PR title/number from the event payload and uses gh to update labels.

Validation

  • Parsed .github/workflows/label-pr.yml with the repository yaml package.
  • pnpm exec prettier -c .github/workflows/label-pr.yml
  • git diff --check

Linked Issues

Unblocks fork PR labeling failures such as #1097.

@Will-hxw Will-hxw requested a review from a team as a code owner April 25, 2026 07:18
@Will-hxw Will-hxw requested review from Luke-Sanderson and removed request for a team April 25, 2026 07:18
@Will-hxw Will-hxw closed this by deleting the head repository Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant