Skip to content

ci: auto-label new issues and PRs by title pattern - #383

Merged
adamgell merged 4 commits into
mainfrom
claude/github-labels-sccm-intune-d6b0d0
Jul 31, 2026
Merged

adamgell merged 4 commits into
mainfrom
claude/github-labels-sccm-intune-d6b0d0

Conversation

@adamgell

@adamgell adamgell commented Jul 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds .github/workflows/label-new-items.yml, triggered on issues: opened and pull_request_target: opened
  • Matches title keywords and conventional-commit prefixes to apply topic labels (sccm, intune, jamf, portal, device, apps, enrollment, windows, security, macos) plus a change-type label (feature, test, build, bug) and enhancement as a baseline
  • Mirrors the manual labeling scheme just applied across the SCCM/Intune/JAMF epics and their children (Epic: SCCM end-to-end diagnostics for future Client and Server workspaces #317, Epic: expand the Intune parser family beyond IME and ESP #356, and associated issues/PRs)
  • Also carries the pre-existing .claude/skills/gh-copilot-review-loop skill (script + docs), which was already committed on this branch before this PR was opened and is not new work from this PR — included here because it's part of this branch's history relative to main

Test plan

  • Dry-ran the labeling logic in Node against all previously-labeled issue/PR titles — output matched the manually-applied labels exactly
  • Validated workflow YAML syntax
  • Addressed Copilot review feedback: dropped unneeded pull-requests: write permission, pinned actions/github-script to a commit SHA, fixed a pagination bug and an outdated-thread-count bug in review_state.py
  • Confirm on a real new issue/PR after merge that labels are applied as expected

🤖 Generated with Claude Code

adamgell and others added 2 commits July 30, 2026 00:02
Vendors the gh-copilot-review-loop skill from jorgeasaurus/agent-skills
so PR feedback can be cycled through Copilot until a clean review lands.

Changes from upstream:
- Repoint the state script at .claude/skills/... instead of $CODEX_HOME,
  which does not exist under Claude Code.
- Document the existing --repo/--pr flags and record provenance.
- Skip agents/openai.yaml (Codex UI metadata) and the committed
  review_state.cpython-314.pyc bytecode.
- Ignore __pycache__ so running the script leaves the tree clean.

Verified with py_compile on Python 3.14.5 and a live run against PR #310,
which returned the correct head SHA, Copilot review count, and thread state.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mirrors the manual labeling scheme applied to the SCCM/Intune/JAMF
epics: matches title keywords and conventional-commit prefixes to
apply topic labels (sccm, intune, jamf, portal, device, apps,
enrollment, windows, security, macos) plus a change-type label
(feature, test, build, bug) and enhancement as a baseline.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 31, 2026 04:59
@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@adamgell, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cf942a6f-b21d-4eb6-9d36-96a81c9b17f7

📥 Commits

Reviewing files that changed from the base of the PR and between a7c6310 and 18cb214.

📒 Files selected for processing (1)
  • .github/workflows/label-new-items.yml

Comment @coderabbitai help to get the list of available commands.

@adamgell adamgell added github_actions Pull requests that update GitHub Actions code enhancement New feature or request labels Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces automation for applying labels to newly opened issues and pull requests based on title patterns, and also adds a new .claude skill for driving Copilot review-loop workflows.

Changes:

  • Add a GitHub Actions workflow that auto-labels new issues (issues: opened) and PRs (pull_request_target: opened) using title regex rules.
  • Add a new .claude/skills/gh-copilot-review-loop skill, including a Python script to fetch thread-aware PR review state via the GitHub GraphQL API.
  • Add Python cache ignores for the new skill directory.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
.github/workflows/label-new-items.yml New workflow to auto-apply topic + change-type labels on new issues/PRs via actions/github-script.
.claude/skills/gh-copilot-review-loop/SKILL.md Documentation for the new Copilot review-loop skill (includes provenance note).
.claude/skills/gh-copilot-review-loop/scripts/review_state.py Script to query PR reviews/threads and summarize Copilot review cycles.
.claude/skills/gh-copilot-review-loop/.gitignore Ignores Python bytecode/cache artifacts for the skill script.

Comment thread .github/workflows/label-new-items.yml Resolved
Comment thread .github/workflows/label-new-items.yml Resolved
Comment on lines +66 to +68
## Provenance

Adapted from `gh-copilot-review-loop` in https://github.com/jorgeasaurus/agent-skills (upstream states no license). The only change is the state-script path, which upstream resolves under `$CODEX_HOME`.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this open for now rather than resolving it myself — this is a repo-policy/compliance call, not something I should decide unilaterally. For context: the SKILL.md already discloses the upstream source and that it "states no license" in its Provenance section, so the caveat isn't hidden. @adamgell, your call on whether to rewrite in-house, seek explicit permission from upstream, or accept as-is.

- Drop unneeded pull-requests:write permission from the labeling
  workflow; addLabels only needs issues:write.
- Pin actions/github-script to a commit SHA to match this repo's
  supply-chain convention (see cmtrace-ci.yml).
- Split review_state.py's reviews/threads pagination into independent
  loops so an exhausted cursor no longer resets the other connection
  back to page 1.
- Exclude outdated threads from unresolved_thread_count so the script
  only reports the threads the loop workflow treats as actionable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.claude/skills/gh-copilot-review-loop/SKILL.md:68

  • The provenance note indicates the upstream repository has no declared license. Carrying adapted text/scripts from an unlicensed source can create compliance risk for this repository; either reimplement the skill content in-house or confirm permission/license compatibility before distributing it.
Adapted from `gh-copilot-review-loop` in https://github.com/jorgeasaurus/agent-skills (upstream states no license). The only change is the state-script path, which upstream resolves under `$CODEX_HOME`.

.github/workflows/label-new-items.yml:34

  • topicRules is adding change-type labels (build, feature) based on keyword matches, but the workflow comment and PR description say change-type labels come from the conventional-commit-style prefix rules. This can produce conflicting labels (e.g., a fix(...) title containing "elevation" would get both bug and feature). Consider keeping topicRules to domain/topic labels only and reserving change-type labels for prefixRules.
              [/build\(macos\)|notarization|developer id signing/i, ['build', 'macos']],
              [/restart as administrator|\belevation\b/i, ['windows', 'security', 'feature']],

.claude/skills/gh-copilot-review-loop/scripts/review_state.py:184

  • --repo parsing will raise a raw ValueError if the argument isn't in owner/name format. Since this is a user-facing CLI, it should fail with a clear message and non-traceback exit code.
        owner, repo = args.repo.split("/", 1)
        number = args.pr

@adamgell
adamgell merged commit 03e55c3 into main Jul 31, 2026
11 checks passed
adamgell added a commit that referenced this pull request Jul 31, 2026
The workflow added in #383 has never succeeded on a pull request. All three
pull_request_target runs so far failed with:

  POST /repos/adamgell/cmtraceopen/issues/<n>/labels
  403 Resource not accessible by integration

The script computes the labels correctly — the failing run for #397 had
body '{"labels":["enhancement","intune","parser","device","feature"]}' — and
then cannot write them.

Cause: labelling a pull request requires `pull-requests: write`, even though
the REST path is under /issues. The workflow declared only `issues: write`,
and because an explicit `permissions:` block replaces the repository default
rather than adding to it, and this repo's default_workflow_permissions is
`read`, the token had no pull-request scope at all. The issues: opened trigger
was unaffected.

Adding `pull-requests: write` is the minimum needed; issue labelling keeps
working through the existing `issues: write`.

Verified: `gh run list --workflow=label-new-items.yml` shows failure on all
three pull_request_target runs to date (#397, and the two before it), and
`gh api repos/:owner/:repo/actions/permissions/workflow` reports
default_workflow_permissions=read.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants