Skip to content

Commit e85318b

Browse files
bpamiriclaude
andauthored
ci(config): move auto-labeler to pull_request_target for fork PRs (#2188)
* test(cli): add dockerized sshd fixture for deploy SSH tests Two openssh-server containers (ports 22022/22023) plus lifecycle helpers. Deterministic test keypair committed to the repo for reproducibility; no production value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(cli): add deploy.yml fixtures for ConfigLoader tests * feat(cli): add ProxyCommands with kamal-proxy hand-off * ci(config): move auto-labeler to pull_request_target for fork prs the `label` job in pr.yml uses the `pull_request` trigger, which github forcibly issues a read-only GITHUB_TOKEN to for fork PRs — overriding the workflow's `permissions: pull-requests: write` declaration. `actions/labeler@v6` then fails with "Resource not accessible by integration" on every fork PR (seen on #2167, #2172, #2180, #2183). split the labeler into its own workflow triggered by `pull_request_target`, which runs in the base repo's context and grants a write-scoped token even for fork PRs. the remaining jobs (commitlint, tests) keep the safer `pull_request` trigger since they execute checked-out PR code. this is the pattern recommended by actions/labeler's docs for repos that accept fork contributions. it's safe because the labeler never checks out the fork's code — it only reads PR metadata and .github/labeler.yml from the base branch via the API. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ee67059 commit e85318b

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

.github/workflows/label.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Auto-Label PR
2+
3+
# Uses pull_request_target so fork PRs receive a write-scoped GITHUB_TOKEN.
4+
# Safe: this workflow never checks out PR code — actions/labeler only reads
5+
# PR metadata and .github/labeler.yml from the base branch via the API.
6+
# No untrusted PR inputs (titles, bodies, branch names) are used in run steps,
7+
# so no workflow injection surface.
8+
on:
9+
pull_request_target:
10+
types: [opened, reopened, synchronize]
11+
branches:
12+
- develop
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
18+
jobs:
19+
label:
20+
name: Auto-Label PR
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/labeler@v6
24+
with:
25+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,9 @@ on:
77

88
permissions:
99
contents: read
10-
pull-requests: write
1110
checks: write
1211

1312
jobs:
14-
label:
15-
name: Auto-Label PR
16-
runs-on: ubuntu-latest
17-
continue-on-error: true
18-
permissions:
19-
contents: read
20-
pull-requests: write
21-
steps:
22-
- uses: actions/labeler@v6
23-
with:
24-
repo-token: ${{ secrets.GITHUB_TOKEN }}
25-
2613
commitlint:
2714
name: Validate Commit Messages
2815
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)