fix: gh CLI was targeting upstream/cursor/plugins instead of this fork - #2
Conversation
The follow-up workflow_dispatch run after #1 merged failed hard on `gh label create`: HTTP 403: Resource not accessible by integration (https://api.github.com/repos/cursor/plugins/labels) Note the URL: gh was targeting cursor/plugins, not this fork. This job adds a remote literally named `upstream` pointing at cursor/plugins (to fetch its history for the rebase), and gh's implicit repo resolution prefers a remote named "upstream" over "origin" when no --repo/GH_REPO is given — a classic gotcha for exactly this fork+ upstream-remote layout. So every unscoped `gh label create`/`gh pr create`/`gh pr list`/`gh pr merge` call in this workflow has actually been aimed at cursor/plugins the whole time, where this token has no access whatsoever. That's the real reason label/PR creation always failed — the previous fix (#1) just stopped hiding it. Set GH_REPO: ${{ github.repository }} at the job level so every `gh` call is unambiguously pinned to this fork regardless of which git remotes exist.
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Note
|
Summary
Follow-up to #1. After that fix merged and the workflow was manually re-run (run 29622408659), it failed hard — which is what #1's changes were meant to do when something is genuinely broken, and something was:
Note the URL:
api.github.com/repos/cursor/plugins/labels—ghwas operating on the upstream repo, notSmailG/claude-cursor-plugins.Root cause
This job runs
git remote add upstream https://github.com/cursor/plugins.gitto fetch upstream's history for the rebase.gh's implicit repository resolution (used whenever a command omits--repo) infers the target repo from git remotes, and it prefers a remote literally namedupstreamoverorigin— a convention aimed at the common "fork now, PR upstream later" workflow. Since this repo's automation remote is named exactlyupstream, every unscopedghcall in this workflow —gh label create,gh pr list,gh pr close,gh pr create,gh pr merge— has been silently targetingcursor/pluginsinstead of this fork, where the job'sGITHUB_TOKENhas (correctly) zero access. That's the actual reason label/PR creation has never worked, going back to the original lag report; #1's permissions/error-surfacing fix was necessary but not sufficient, since the token permissions were only ever wrong for a repoghshould never have touched in the first place.Fix
Set
GH_REPO: ${{ github.repository }}as a job-level env var, so everyghinvocation in every step is unambiguously pinned toSmailG/claude-cursor-pluginsregardless of which git remotes exist. Puregitcommands (git fetch upstream,git rebase upstream/main, etc.) are untouched sinceGH_REPOonly affects theghCLI.Test plan
workflow_dispatch) and confirmgh label createsucceeds againstSmailG/claude-cursor-pluginsand a real sync PR appears.::warning::annotation from fix: sync-upstream workflow silently fails to open PRs, leaving fork behind #1 if "Allow auto-merge" is off for the repo.Generated by Claude Code