This repository practices what it preaches: democratic infrastructure management through pull requests. The worlddriven organization is managed entirely through code, with REPOSITORIES.md as the source of truth.
As described in our vision for Phase 2: Transparent Service Management, infrastructure decisions should be made democratically, just like code. This automation system enables:
- Democratic control: Any contributor can propose organization changes via pull requests
- Transparency: All infrastructure changes are visible in git history
- Consistency: Standard configurations are automatically enforced
- Accountability: Changes are tied to commits and contributors
REPOSITORIES.md defines all repositories in the worlddriven organization. When this file changes, automation ensures GitHub matches the desired state.
## repository-name
- Description: Brief description of the repository
- Topics: topic1, topic2, topic31. Pull Request Phase (Drift Detection)
- You modify REPOSITORIES.md and create a PR
- GitHub Actions automatically runs drift detection
- A comment appears showing exactly what will change:
- Repositories to be created
- Descriptions/topics to be updated
- Repositories to be deleted (with protected repo warnings)
- Settings to be standardized
2. Review Phase (Democratic Decision)
- Contributors review the proposed changes
- Discussion happens in the PR
- Worlddriven's voting system determines merge timing
3. Merge Phase (Automatic Sync)
- PR merges to main
- Sync workflow executes with APPLY mode
- Changes are applied to GitHub organization:
- Creates new repositories
- Updates existing repositories
- Deletes repositories not in REPOSITORIES.md
- Applies standard configurations
- Sets up branch protection
- Commit comment shows sync results
- Issue created if any failures occur
All worlddriven repositories automatically receive these settings to support democratic governance:
- Merge strategy: Squash only (1 PR = 1 commit for fair voting)
- Auto-merge: Disabled (worlddriven controls merging)
- Branch cleanup: Delete branches after merge
- Update branch: Disabled
Applied to default branch (usually main):
- Pull request required: All changes must go through PR workflow
- No force push: Prevents history rewriting
- No branch deletion: Protects main branch
- Allowed merge method: Squash only
- No bypass actors: True democracy applies to everyone
New repositories are created with:
- Public visibility
- Initial README.md file (created via auto_init)
- Issues, Projects, and Wiki enabled
- Standard settings pre-applied
- Branch protection ruleset active
Three infrastructure repositories are protected from automatic deletion:
- documentation - This repository (organization management)
- core - The worlddriven application server
- webapp - The worlddriven web interface
These repositories can still be updated (descriptions, topics, settings) but won't be deleted if removed from REPOSITORIES.md. This prevents accidental deletion of critical infrastructure.
Triggers: PRs that modify REPOSITORIES.md, scripts, or workflows
Purpose: Show what will happen before changes merge
Actions:
- Parses REPOSITORIES.md
- Fetches current GitHub organization state
- Compares desired vs actual state
- Runs sync in dry-run mode (no changes made)
- Comments on PR with drift report and sync preview
- Updates existing comment instead of creating duplicates
Example Output:
# Drift Detection Report
Missing (in REPOSITORIES.md but not GitHub):
- new-project
Extra (in GitHub but not REPOSITORIES.md):
- old-experiment
Description Drift:
- existing-repo: "Old description" → "Updated description"
# Dry-Run Sync Preview
Would create:
- new-project (Description: A new worlddriven project)
Would delete:
- old-experiment (unprotected repository)
Triggers: Push to main branch
Purpose: Apply infrastructure changes to GitHub
Permissions:
- Runs only on worlddriven organization (not forks)
- Requires WORLDDRIVEN_GITHUB_TOKEN secret
Actions:
- Executes sync-repositories.js with --apply flag
- Creates/updates/deletes repositories
- Applies standard configurations
- Posts commit comment with results
- Creates issue if failures occur
- Adds report to workflow summary
Example Output:
✅ APPLY Repository Sync Report
Summary: 3 total actions
- Create: 1
- Update descriptions: 1
- Delete: 1
✅ Successfully Applied (3)
- Create new-project
- Update description for existing-repo
- Delete old-experiment
Triggers: All PRs
Purpose: Validate automation scripts work correctly
Actions:
- Runs unit tests for parse-repositories.js
- Validates REPOSITORIES.md syntax
- Ensures scripts can execute
Main synchronization engine that applies changes to GitHub.
Usage:
# Dry-run (show what would happen)
WORLDDRIVEN_GITHUB_TOKEN=xxx node scripts/sync-repositories.js
# Apply changes
WORLDDRIVEN_GITHUB_TOKEN=xxx node scripts/sync-repositories.js --applyCapabilities:
- Create repositories with standard settings
- Update repository descriptions and topics
- Delete repositories (except protected ones)
- Apply/enforce standard repository settings
- Create branch protection rulesets
- Initialize empty repositories
Compares desired state (REPOSITORIES.md) with actual state (GitHub).
Detects:
- Missing repositories
- Extra repositories
- Description differences
- Topic differences
Parses REPOSITORIES.md markdown format.
Features:
- Extracts repository definitions
- Validates required fields (name, description)
- Skips code blocks and examples
- Handles optional topics
Fetches current GitHub organization repository state via API.
Returns:
- Repository names
- Descriptions
- Topics
- Handles pagination
The sync automation uses a GitHub Personal Access Token stored as WORLDDRIVEN_GITHUB_TOKEN in repository secrets.
Required permissions:
repo- Full control of repositoriesadmin:org- Manage organization settingsdelete_repo- Delete repositories
- Forks: Workflows are restricted to worlddriven organization only
- Tests: Test workflow runs on all repos including forks (no secrets needed)
- Secrets: Organization secrets are not accessible to fork PRs
- Protected repositories: Cannot be auto-deleted
- Dry-run preview: See changes before merge
- Atomic operations: Each action is independent
- Failure isolation: One failure doesn't stop other operations
- Audit trail: All changes visible in git history and workflow logs
- Create a PR modifying REPOSITORIES.md:
## my-new-project
- Description: An experimental worlddriven integration
- Topics: experiment, integration, worlddriven-
Drift detection comments on your PR showing it will create the repository
-
After PR merges, sync workflow:
- Creates
worlddriven/my-new-project - Sets description and topics
- Applies standard settings
- Creates branch protection ruleset
- Initializes with README.md
- Creates
- Edit description in REPOSITORIES.md:
## my-new-project
- Description: Production-ready worlddriven integration (updated!)
- Topics: integration, worlddriven, production-
Drift detection shows description and topic changes
-
After merge, sync workflow updates GitHub metadata
-
Remove repository section from REPOSITORIES.md
-
Drift detection warns:
- If protected: "Would skip - protected repository"
- If unprotected: "Would delete repository-name"
-
After merge:
- Protected repos: Skipped with warning in logs
- Unprotected repos: Deleted from GitHub
Important: Repository deletion is permanent. Ensure you have backups.
If sync fails, an issue is automatically created with:
- Error details
- Which actions failed
- Commit SHA that triggered the failure
Common failures:
- 403 errors: Token permissions issue
- 409 errors: Conflicts (e.g., repository already exists)
- Rate limits: Too many API calls (wait and retry)
If automation fails and manual fixes are needed:
- Fix the issue in GitHub directly
- Update REPOSITORIES.md to match actual state
- Next sync will detect no drift
To test automation changes locally:
# Install dependencies
npm install
# Run tests
npm test
# Dry-run sync (requires token)
export WORLDDRIVEN_GITHUB_TOKEN=your_token
node scripts/sync-repositories.jsSee CONTRIBUTING.md for details on:
- How to propose organization changes
- Automation script development
- Testing guidelines
- Security considerations
This automation embodies worlddriven's core principle: those who contribute should govern. By managing infrastructure through pull requests, we ensure:
- Transparency: All decisions visible in git history
- Democracy: Anyone can propose changes
- Meritocracy: Contribution weight determines influence
- Accountability: Changes are attributed and reversible
The automation removes gatekeepers while maintaining safety through standard configurations and protected repositories.