Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/2155-heartbeat-fork-pr-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@bradygaster/squad-cli": patch
"@bradygaster/squad-sdk": patch
---

Fix `squad-heartbeat.yml`'s "Repair orphaned squad labels" step 403ing when a fork PR closes.

`GITHUB_TOKEN` is forced read-only for `pull_request`-triggered workflow runs originating from a fork, regardless of the workflow's declared `permissions:` block, so `issues.addLabels` was rejected with `403 Resource not accessible by integration`. The trigger is switched to `pull_request_target` across all 5 synced copies (`.github/workflows/`, `templates/workflows/`, `packages/squad-cli/templates/workflows/`, `packages/squad-sdk/templates/workflows/`, `.squad-templates/workflows/`), which runs with base-repo token permissions regardless of fork origin.

This is safe because the `actions/checkout` step never overrides `ref:` (always checks out the base ref, never the fork head), and no step reads or executes anything from the triggering PR's content.
8 changes: 7 additions & 1 deletion .github/workflows/squad-heartbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ on:
# React to completed work or new squad work
issues:
types: [closed, labeled]
pull_request:
# pull_request_target (not pull_request): GITHUB_TOKEN is forced read-only
# for `pull_request` events triggered by a fork, so write steps below
# (addLabels/createComment) 403 on fork PR closes (#2080-class bug).
# Safe here because the checkout step below has no `ref:` override, so it
# always checks out the BASE ref — no fork code or fork-controlled input
# is ever read or executed by this job.
pull_request_target:
types: [closed]

# Manual trigger
Expand Down
8 changes: 7 additions & 1 deletion .squad-templates/workflows/squad-heartbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ on:
# React to completed work or new squad work
issues:
types: [closed, labeled]
pull_request:
# pull_request_target (not pull_request): GITHUB_TOKEN is forced read-only
# for `pull_request` events triggered by a fork, so write steps below
# (addLabels/createComment) 403 on fork PR closes.
# Safe here because the checkout step below has no `ref:` override, so it
# always checks out the BASE ref — no fork code or fork-controlled input
# is ever read or executed by this job.
pull_request_target:
types: [closed]

# Manual trigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ on:
# React to completed work or new squad work
issues:
types: [closed, labeled]
pull_request:
# pull_request_target (not pull_request): GITHUB_TOKEN is forced read-only
# for `pull_request` events triggered by a fork, so write steps below
# (addLabels/createComment) 403 on fork PR closes.
# Safe here because the checkout step below has no `ref:` override, so it
# always checks out the BASE ref — no fork code or fork-controlled input
# is ever read or executed by this job.
pull_request_target:
types: [closed]

# Manual trigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ on:
# React to completed work or new squad work
issues:
types: [closed, labeled]
pull_request:
# pull_request_target (not pull_request): GITHUB_TOKEN is forced read-only
# for `pull_request` events triggered by a fork, so write steps below
# (addLabels/createComment) 403 on fork PR closes.
# Safe here because the checkout step below has no `ref:` override, so it
# always checks out the BASE ref — no fork code or fork-controlled input
# is ever read or executed by this job.
pull_request_target:
types: [closed]

# Manual trigger
Expand Down
8 changes: 7 additions & 1 deletion templates/workflows/squad-heartbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ on:
# React to completed work or new squad work
issues:
types: [closed, labeled]
pull_request:
# pull_request_target (not pull_request): GITHUB_TOKEN is forced read-only
# for `pull_request` events triggered by a fork, so write steps below
# (addLabels/createComment) 403 on fork PR closes.
# Safe here because the checkout step below has no `ref:` override, so it
# always checks out the BASE ref — no fork code or fork-controlled input
# is ever read or executed by this job.
pull_request_target:
types: [closed]

# Manual trigger
Expand Down
Loading