feat(just): Add repository branch protection justfile entries - #27
Merged
Conversation
aRustyDev
force-pushed
the
pr/just-protect-repo
branch
from
December 5, 2025 21:44
79081a0 to
dd6e9d8
Compare
…epo default - Add `init` recipe for interactive first-time setup - Add `set-target` recipe for non-interactive target_repo changes - Add `target_repo` global variable as default for all repo parameters - Replace shell `$(dirname "$0")` with `justfile_directory()` - Replace shell path checks with `path_exists()` - Add `_require-repo`, `_require-file`, `_require-dir` validation helpers - Remove redundant `echo ""` statements throughout - Remove unnecessary shell variable assignments (use just params directly) - Mark internal recipes with `[private]` attribute - Simplify heredocs to inline strings for just compatibility
Split branch protection rulesets into two categories: - Core protection (no bypass): deletion, force-push, linear history - PR reviews (with bypass): review requirements for aRustyDev This enables the user aRustyDev to bypass the required_approving_review_count rule while still being subject to all core branch protections. New files: - .github/rulesets/main-pr-reviews.json - .github/rulesets/integration-pr-reviews.json Modified: - .github/rulesets/main-branch-protection.json (removed PR rules) - .github/rulesets/integration-branch-protection.json (removed PR rules) - .ai/docs/strategies/protect-github-repo.md (updated documentation)
GitHub repository-level rulesets do not support "User" as an actor_type. Valid types are: Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey. Changed bypass_actors to use: - actor_type: "RepositoryRole" - actor_id: 5 (Repository Admin/Owner role) This allows repository admins to bypass PR review requirements while still being subject to core branch protections.
Added --silent flag to gh api commands to prevent the JSON response from being piped through a pager (vim/less), allowing the recipe to run non-interactively.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds justfile entries for protecting GitHub repositories using branch rulesets, and refactors the entire justfile to use just built-in functions and a global
target_repovariable.Changes
New Features
Branch Protection Recipes: New justfile recipes for managing repository branch protection:
protect-repo [repo]- Apply all branch protection rulesetsapply-ruleset [repo] <file>- Apply a single ruleset from JSON fileunprotect-repo [repo]- Remove all rulesetslist-rulesets [repo]- List all rulesets for a repositoryInitialization System:
init- Interactive first-time setup that setstarget_reposet-target <repo>- Non-interactive way to change target repositoryNew Files
.github/rulesets/main-branch-protection.json- Ruleset configuration for main branch.github/rulesets/integration-branch-protection.json- Ruleset configuration for integration branch.ai/docs/strategies/protect-github-repo.md- Strategy documentationRefactoring
Built-in Functions: Replaced shell patterns with just built-ins:
justfile_directory()instead of$(dirname "$0")justfile()for self-modificationpath_exists()for file/directory validationerror()for clean error handlingGlobal Variables:
target_repo- set viainitor override per-commandjustfile_dir,labels_file,rulesets_dir,bundles_dirpath variablesValidation Helpers:
_require-repo- Ensures repo parameter is set_require-file- Ensures file exists_require-dir- Ensures directory existsCode Cleanup:
echo ""statements[private]Protection Rules Applied
Main Branch
Integration Branch
Usage
Commits
feat(just): Adding justfile entries for protecting repositorydocs(just): Documenting justfile entries for protecting repositoryrefactor(just): Use built-in functions, add init recipe, and target_repo default