Repository navigation
feat(labels): scope org-label sync to a repo list; seed catalog labels on PR-apply - #266
Conversation
…s on PR-apply
Fixes both halves of the "labels auto-created flat gray on first use" problem on
freshly onboarded repos (labels stayed gray until the weekly org sweep):
1. sync-org-labels gains an optional `repos` input (comma / space / newline
separated, each with or without an owner/ prefix). When set, the sync targets
just those repos instead of always sweeping /orgs/{org}/repos; empty keeps the
full-org sweep, so the weekly cron / manual org dispatch is unchanged. Plumbed
through the reusable workflow and the composite action.
2. sync-pr-labels now seeds/corrects each label it is about to apply from
data/github-labels.json before applying it (new `ensure-catalog-labels` input,
default true), so POST /issues/{n}/labels finds the labels already present with
the catalog's color/description instead of silently auto-creating them flat
gray. Cheap in steady state (one list call, zero writes once correct).
The apply-time ensure is deliberately NON-destructive — it only creates or
corrects the labels being applied and never deletes, unlike the full org sync
(which deletes any repo label absent from the catalog). Triggering the full
destructive sync on every PR-label apply would strip a repo's custom labels
mid-PR, so the on-demand single-repo full sync is exposed via part 1's `repos`
input instead. Best-effort: a missing catalog or insufficient token scope warns
and lets the apply proceed unchanged.
Fixes #263
There was a problem hiding this comment.
🟡 Changes recommended
The new catalog-seeding path can still fail the action on a malformed-but-parseable label catalog, contradicting the intended “best-effort, never block apply” behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR enhances the org label management tooling by (1) allowing org label sync to be scoped to an explicit repo list and (2) ensuring PR label application seeds/corrects labels from the shared label catalog so repos don’t get GitHub’s default gray auto-created labels.
Changes:
- Add a
reposinput to the org-label sync workflow and underlying sync job/action to optionally scope syncing to specific repositories. - Extend the PR label sync step with an
ensure-catalog-labelsinput (default on) that creates/updates the labels being applied based ondata/github-labels.jsonbefore applying them.
File summaries
| File | Description |
|---|---|
| .github/workflows/workflow-sync-org-labels.yml | Adds a repos workflow input and forwards it into the sync job to allow scoped org-label sync runs. |
| .github/actions/github/jobs/sync-org-labels/action.yml | Adds repos input and passes it to the sync script via REPOS env var. |
| .github/actions/github/jobs/sync-org-labels/sync.mjs | Implements scoped repo selection when REPOS is provided; otherwise preserves full-org sweep behavior. |
| .github/actions/github/steps/sync-pr-labels/action.yml | Adds ensure-catalog-labels input (default true) to control catalog seeding behavior. |
| .github/actions/github/steps/sync-pr-labels/action.mjs | Implements best-effort label catalog seeding/correction before applying PR labels. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…atalog A data/github-labels.json that parses as valid JSON but isn't an array (e.g. an object) passed the read/parse try/catch, then threw an uncaught TypeError at `for (const entry of catalog)` — propagating to the top-level handler and failing the whole label-apply step, the opposite of the documented best-effort contract. Add an Array.isArray guard that skips cleanly with a warning, and make the read/parse warning resilient to a non-Error throw. Addresses Copilot review on PR #266.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are additive, backward-compatible, and the new catalog-seeding behavior is explicitly best-effort with appropriate guards to avoid blocking label application.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The new catalog-label ensure path can redundantly re-ensure duplicate labels (extra API calls/noisy warnings) unless label names are deduplicated first.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
Addressing Copilot review on #266: ensureCatalogLabels mapped the incoming labels straight to catalog entries, so multiple aliases resolving to the same canonical label ensured it more than once — redundant API calls and a noisy 422 on the second create. Resolve to entries deduped by canonical (lowercased) name.
There was a problem hiding this comment.
🔵 Needs a closer look
The new REPOS parsing can yield empty repo names (or a misleading 0-repo scoped run) due to filtering before stripping owner/, leading to invalid API calls or unintended no-ops.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
.github/actions/github/jobs/sync-org-labels/sync.mjs:435
REPOSparsing filters empties before stripping an optionalowner/prefix, so inputs likeCLDMV/(or separators-only like,) can produce an empty repo name and/or an emptynameslist while still taking the scoped-sync path. That results in invalid/repos/${ORG}/API calls or a misleading “scoped to 0 repos” no-op instead of falling back to the default full-org sweep.
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
…n empty Addressing a Copilot suppressed finding on #266: the REPOS scoping parse ran .filter(Boolean) BEFORE stripping the optional owner/ prefix, so 'CLDMV/' (or a separators-only input) produced an empty repo name → invalid GET /repos/{org}/ calls, or a misleading 'scoped to 0 repos' no-op instead of the full-org sweep. Now strip owner/ and trim first, THEN filter empties, and fall back to the full-org sweep (with a note) when nothing resolves.
|
Addressed the suppressed finding from the last review ( |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are self-contained, align with existing API helper patterns in the repo, and include appropriate best-effort/error-tolerant behavior for the new label-seeding step.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
🐛 Bug Fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
No other changes
👥 Contributors