feat: cli cmd + action to copy repo rulesets#183
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
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()andcopy_ruleset()plus unit tests. - Expose new CLI commands
list-rulesetsandcopy-rulesetwith Click-based tests. - Introduce a new composite action
copy-rulesetwith 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. |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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>
| @@ -0,0 +1,28 @@ | |||
| name: copy-ruleset | |||
|
|
|||
| on: | |||
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
Implemented in a565009.
The example now includes additional triggers:
pushonmain/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.
Changes
list-rulesetsandcopy-rulesetcopy-rulesetand example workflowexamples/copy-ruleset.ymlwith additional plausible triggers:push(including first push scenarios such as repos created from templates)repository_dispatchscheduleRULESET_SOURCE_REPO,RULESET_NAME, optionalRULESET_TARGET_REPO) and guarded execution when required values are missingUseful for ensuring repos adhere to standard rulesets
Issues
NA
PR Checklist
(
Strikethroughany points that are not applicable.)CHANGELOG.mdwith a short description of any user-facing changes and reference the PR number. Guidelines: https://keepachangelog.com/en/1.1.0/