Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jfouret/github_protect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repository Management Tools

Python scripts for managing GitHub repositories and branch protection using the GitHub REST API.

Scripts

list_repos.py - Repository Lister

Lists all repositories in a GitHub organization and exports them to private.list and public.list.

python list_repos.py <organization_name>

protect_branches.py - Branch Protection

Protects main branches of repositories listed in a file with pull request requirements.

python protect_branches.py <repo_list_file>

Setup

  1. Install dependencies: pip install -r requirements.txt
  2. Set GitHub token:
    • Environment: export GITHUB_TOKEN=your_token
    • File: echo "your_token" > github-token.txt

Branch Protection Policy

  • Requires pull requests for main branch
  • Code owner reviews required (if CODEOWNERS exists)
  • Repository owners can bypass restrictions
  • No minimum approval count
  • Allows force pushes and deletions

Usage Examples

# List all repos in organization
python list_repos.py nexomis

# Protect repositories from a list
python protect_branches.py test.list
python protect_branches.py private.list

File Formats

Repository list files contain one repo per line:

owner/repo1
owner/repo2

Requirements

  • Python 3.6+
  • GitHub token with repo scope
  • Admin access for branch protection

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages