Skip to content

Repository files navigation

GitHub Organization Settings

Automated governance for GitHub repository settings across the gamaware organization. Discovers all repositories, compares their configuration against a defined baseline, applies corrections, and reports drift via GitHub Issues.

Why This Exists

Manually configuring GitHub repository settings is error-prone and does not scale. When you create a new repository or change a policy (e.g., requiring linear history), every repo needs updating. This automation ensures that all repositories under gamaware converge to a single standard — the same merge strategies, branch protection rules, security scanning, and scaffolding files.

How It Works

Weekly (Sunday 00:00 UTC)
|
v
+-------------------+
| Discover repos | -- gh repo list (excludes archived + excluded)
+-------------------+
|
v
+-------------------+
| Compare settings | -- current state vs config/baseline.json
+-------------------+
|
v
+-------------------+
| Apply corrections | -- PATCH/PUT via GitHub API (--apply mode)
+-------------------+
|
v
+-------------------+
| Generate report | -- Markdown report + GitHub Issue if drift found
+-------------------+

The workflow also checks for repositories created in the last 7 days and opens a GitHub Issue to flag them.

What Gets Enforced

Merge Strategy

Every repository is locked to squash-merge only. This keeps main history linear and readable.

SettingValueWhy
allow_squash_mergetrueSingle clean commit per PR
allow_merge_commitfalsePrevents noisy merge commits
allow_rebase_mergefalsePrevents rebase without squash
squash_merge_commit_titlePR_TITLEConsistent commit messages
squash_merge_commit_messagePR_BODYPR description becomes commit body
delete_branch_on_mergetrueAuto-cleanup merged branches
allow_auto_mergetrueMerge automatically when checks pass
allow_update_branchtrueKeep PR branches current with base

Repository Features

Unused features are disabled to reduce attack surface and clutter.

SettingValueWhy
has_wikifalseDocumentation lives in the repo
has_projectsfalseNot used for project tracking
has_discussionsfalseNot used for discussions
has_issuestruePrimary issue tracker

Security

Secret scanning catches leaked credentials before they reach main. Vulnerability alerts flag known CVEs in dependencies.

SettingValueWhy
Secret scanningenabledDetect leaked tokens and keys
Push protectionenabledBlock pushes containing secrets
Vulnerability alertsenabledDependabot CVE notifications

Branch Protection (main)

All changes go through PRs with at least one review. Linear history ensures clean git log and bisectability.

SettingValueWhy
Required reviews1At least one approval before merge
Dismiss stale reviewstrueNew pushes invalidate old approvals
Require CODEOWNERStrueOwners must review their areas
Required status checksstrictBranch must be up to date
Required linear historytrueNo merge commits on main
Required conversation resolutiontrueAll comments must be resolved
Enforce adminsfalseAdmins can bypass when needed

Rulesets

The Copilot code review ruleset is enforced on every repository's default branch. The sync script creates it if missing and verifies enforcement is active.

RulePurpose
deletionPrevent branch deletion
non_fast_forwardPrevent force pushes
copilot_code_reviewRequire Copilot review on PRs

Labels

Standard labels are created on every repo for consistent issue triage.

LabelColorPurpose
bugredSomething is broken
enhancementcyanNew feature or improvement
documentationblueDocs updates
securityyellowSecurity-related
settings-driftgoldSettings mismatch (used by this repo)
new-repogreenNew repo discovered (used by this repo)

Required Files

Every repo must contain these files. Missing files are flagged in the report (not auto-created, since content is repo-specific).

FilePurpose
LICENSELegal terms (MIT)
README.mdProject overview
.gitignoreExclude build artifacts and secrets
CODEOWNERSAssign default reviewers
CONTRIBUTING.mdContribution guidelines
SECURITY.mdVulnerability disclosure policy
CLAUDE.mdClaude Code project instructions
.pre-commit-config.yamlLocal linting and validation
.coderabbit.yamlCodeRabbit auto-review configuration
.github/copilot-instructions.mdCopilot code review instructions
.github/dependabot.ymlAutomated dependency updates
.github/PULL_REQUEST_TEMPLATE.mdPR checklist template

Metadata Checks (Advisory)

Repos missing a description or topics are flagged in the report for manual attention. These are not auto-fixed because they require human judgment.

Default Branch Check

Repos not using main as the default branch are flagged and can be corrected in --apply mode.

Repository Structure

github-org-settings/
├── .claude/
│ ├── settings.json # Claude Code hooks config
│ ├── hooks/
│ │ └── post-edit.sh # Auto-format on edit
│ └── skills/
│ ├── audit/ # /audit — dry-run settings check
│ │ └── SKILL.md
│ ├── add-repo-override/ # /add-repo-override — add exception
│ │ └── SKILL.md
│ └── exclude-repo/ # /exclude-repo — exclude a repo
│ └── SKILL.md
├── .github/
│ ├── actions/
│ │ ├── security-scan/ # Composite: Semgrep + Trivy
│ │ │ └── action.yml
│ │ ├── sync-settings/ # Composite: settings sync
│ │ │ └── action.yml
│ │ └── update-pre-commit-composite/ # Composite: hook updates
│ │ └── action.yml
│ ├── workflows/
│ │ ├── sync-settings.yml # Weekly settings sync + reports
│ │ ├── quality-checks.yml # PR/push linting and validation
│ │ ├── security.yml # SAST + SCA scanning
│ │ └── update-pre-commit-hooks.yml # Weekly hook updates
│ ├── ISSUE_TEMPLATE/
│ │ ├── settings-bug.md
│ │ └── settings-request.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ ├── copilot-instructions.md
│ └── dependabot.yml
├── scripts/
│ ├── sync-repo-settings.sh # Main sync logic
│ └── generate-report.sh # Report parser for CI
├── config/
│ ├── baseline.json # Settings enforced on all repos
│ └── overrides.json # Per-repo exceptions
├── docs/
│ ├── architecture.md # System architecture overview
│ ├── adr/
│ │ ├── README.md
│ │ ├── 001-settings-governance.md
│ │ └── 002-sync-architecture.md
│ └── runbooks/
│ ├── README.md
│ ├── add-setting.md # How to add a new setting
│ ├── exclude-repo.md # How to exclude a repo
│ ├── handle-drift.md # How to respond to drift
│ └── onboard-repo.md # How to onboard a new repo
├── .coderabbit.yaml # CodeRabbit auto-review config
├── .gitignore
├── .markdownlint.yaml
├── .yamllint.yml
├── .pre-commit-config.yaml
├── .secrets.baseline
├── zizmor.yml # GitHub Actions security config
├── CLAUDE.md # Claude Code project instructions
├── CODEOWNERS
├── CONTRIBUTING.md
├── LICENSE
├── SECURITY.md
└── README.md

Usage

Automatic (Weekly)

The sync-settings.yml workflow runs every Sunday at midnight UTC in --apply mode. It:

  1. Discovers all non-archived repos
  2. Compares settings against config/baseline.json
  3. Applies corrections via the GitHub API
  4. Posts a Job Summary with the full report
  5. Opens a GitHub Issue if drift was detected
  6. Closes previous drift issues if all repos are compliant
  7. Flags new repos created in the last 7 days

Manual Trigger

# Dry run (validation only)
gh workflow run sync-settings.yml -f mode="--dry-run"# Apply settings
gh workflow run sync-settings.yml -f mode="--apply"

Local Testing

# Dry run
./scripts/sync-repo-settings.sh --dry-run
# Apply
./scripts/sync-repo-settings.sh --apply

Configuration

Baseline Settings

Edit config/baseline.json to change the enforced settings. Changes go through PR review like any code change.

Per-Repo Overrides

Edit config/overrides.json to set repo-specific exceptions. The most common override is required_status_checks.contexts since each repo has different CI jobs.

Excluding Repositories

Add repo names to the excluded array in config/overrides.json:

{
"excluded": ["some-repo-to-skip"]
}

Secrets Required

SecretPurposeScopes
ORG_SETTINGS_PATGitHub PAT for API accessrepo, admin:org

Code Review

  • GitHub Copilot: auto-review via ruleset (enforced automatically by the sync script)
  • CodeRabbit: auto-review on PRs via .coderabbit.yaml

Note: CodeRabbit must be enabled manually per repository through the CodeRabbit dashboard. No API exists to automate this step. After installing the GitHub App, select "All repositories" to cover new repos automatically, or add repos individually through the dashboard.

CI/CD Pipelines

WorkflowTriggerPurpose
sync-settings.ymlWeekly + manualSettings enforcement
quality-checks.ymlPR + push to mainMarkdown, YAML, shell, structure
security.ymlPR + push to mainSemgrep SAST + Trivy SCA
update-pre-commit-hooks.ymlWeekly + manualAuto-update hook versions

Author

Jorge Alejandro Garcia Martinez (@gamaware)

License

MIT

About

Automated governance for GitHub repository settings across the gamaware organization

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages