Skip to content

ci: label pull requests from forks too - #161

Merged
bvweerd merged 1 commit into
devfrom
claude/labeler-fork-prs
Oct 6, 2026
Merged

bvweerd merged 1 commit into
devfrom
claude/labeler-fork-prs

Conversation

@bvweerd

@bvweerd bvweerd commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Problem

On bvweerd/simple_pid_controller#158, which came from a fork, the check "Automatically label PRs by changed files" failed:

HttpError: Resource not accessible by integration - https://docs.github.com/rest/issues/labels#set-labels-for-an-issue

For a pull request from a fork, the pull_request event always gets a read-only GITHUB_TOKEN. The pull-requests: write in the workflow makes no difference there.

Change

label-prs.yml now triggers on pull_request_target instead of pull_request. The workflow then runs from the base branch with a writable token.

That is safe here because no step checks out or runs code from the pull request. actions/labeler reads the changed file names through the API, and the github-script step reads only the title. A comment in the workflow records that this has to stay that way.

Side effect: changes to label-prs.yml or .github/pr-labeler.yml in a pull request only take effect once they are merged, because the workflow and its config come from the base branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV


Generated by Claude Code

For a pull request from a fork, the pull_request event gets a read-only
token regardless of the permissions block, so the labeler failed with
"Resource not accessible by integration" (seen on #158). Run on
pull_request_target instead, which uses the base branch's workflow and a
writable token. Neither step checks out or runs the pull request's code,
which is what keeps that safe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV
@bvweerd
bvweerd merged commit 6ebf78d into dev Oct 6, 2026
@bvweerd
bvweerd deleted the claude/labeler-fork-prs branch October 6, 2026 06:23
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.

2 participants