Skip to content

feat: cli cmd + action to copy repo rulesets#183

Open
kelly-sovacool wants to merge 15 commits into
mainfrom
copy-gh-ruleset
Open

feat: cli cmd + action to copy repo rulesets#183
kelly-sovacool wants to merge 15 commits into
mainfrom
copy-gh-ruleset

Conversation

@kelly-sovacool

@kelly-sovacool kelly-sovacool commented Jun 25, 2026

Copy link
Copy Markdown
Member

Changes

  • New CLI commands: list-rulesets and copy-ruleset
  • New action: copy-ruleset and example workflow
  • Expanded examples/copy-ruleset.yml with additional plausible triggers:
    • push (including first push scenarios such as repos created from templates)
    • repository_dispatch
    • schedule
  • Updated the copy-ruleset docs/example to support non-manual runs using repository variables (RULESET_SOURCE_REPO, RULESET_NAME, optional RULESET_TARGET_REPO) and guarded execution when required values are missing

Useful for ensuring repos adhere to standard rulesets

Issues

NA

PR Checklist

(Strikethrough any points that are not applicable.)

  • This comment contains a description of changes with justifications, with any relevant issues linked.
  • Write unit tests for any new features, bug fixes, or other code changes.
  • Update docs if there are any API changes.
  • Update CHANGELOG.md with a short description of any user-facing changes and reference the PR number. Guidelines: https://keepachangelog.com/en/1.1.0/

@kelly-sovacool kelly-sovacool requested a review from Copilot June 25, 2026 18:50

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

Adds new GitHub ruleset tooling to this repo’s ccbr_actions CLI and composite action catalog, enabling teams to list and copy repository rulesets via the GitHub API to standardize governance across repositories.

Changes:

  • Add GitHub API helpers list_rulesets() and copy_ruleset() plus unit tests.
  • Expose new CLI commands list-rulesets and copy-ruleset with Click-based tests.
  • Introduce a new composite action copy-ruleset with docs and an example workflow; update CHANGELOG and ignore rules for Quarto outputs.

Reviewed changes

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

Show a summary per file
File Description
src/ccbr_actions/github.py Implements list_rulesets/copy_ruleset GitHub API helpers.
src/ccbr_actions/__main__.py Adds Click CLI commands wiring for listing/copying rulesets.
tests/test_github.py Adds unit tests for the new GitHub API helper functions.
tests/test_cli.py Adds CLI tests for list-rulesets and copy-ruleset.
copy-ruleset/action.yml New composite action that runs copy_ruleset() in a workflow step.
copy-ruleset/README.qmd New action documentation and usage examples.
examples/copy-ruleset.yml Example workflow to invoke the new action.
CHANGELOG.md Adds a development-version entry for the new feature(s).
.gitignore Ignores Quarto and Posit artifacts.
SECURITY.md Minor formatting cleanup.

Comment thread src/ccbr_actions/__main__.py Outdated
Comment thread src/ccbr_actions/github.py Outdated
Comment thread src/ccbr_actions/github.py Outdated
Comment thread CHANGELOG.md Outdated
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.81%. Comparing base (24a3587) to head (a5344f5).

Files with missing lines Patch % Lines
src/ccbr_actions/__main__.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
+ Coverage   94.43%   97.81%   +3.38%     
==========================================
  Files          11       11              
  Lines         557      595      +38     
==========================================
+ Hits          526      582      +56     
+ Misses         31       13      -18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ccbr-bot Bot and others added 8 commits June 25, 2026 18:56
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread examples/copy-ruleset.yml
@@ -0,0 +1,28 @@
name: copy-ruleset

on:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot add other triggers, e.g. could this workflow run when a repo is created from a template for the first time? what other plausible triggers could be useful?

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.

Implemented in a565009.

The example now includes additional triggers:

  • push on main/master (covers the initial push when a repo is created from a template)
  • repository_dispatch (for org-level automation)
  • schedule (for periodic ruleset sync)

I also added fallback repository variables (RULESET_SOURCE_REPO, RULESET_TARGET_REPO, RULESET_NAME) so non-manual triggers can run without workflow_dispatch inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants