Repository Settings Management
This document describes how repository settings are managed programmatically using GitHub Actions.
Overview
The driftless-hq/driftless repository uses an automated workflow to enforce repository settings consistently. Settings are defined in .github/repo-settings.yml and applied automatically when changes are made to the .github directory.
Configuration File
All repository settings are defined in .github/repo-settings.yml. This file includes:
Repository Settings
- Basic Information: Description, homepage URL, topics
- Features: Issues, Wiki, Projects, Downloads
- Merge Settings: Squash merge, merge commits, rebase merging, auto-merge
- Branch Management: Auto-delete branches after merge
Branch Protection
Branch protection rules for the main branch include:
-
Pull Request Reviews
- Minimum number of required approvals (default: 1)
- Dismiss stale reviews on new commits
- Code owner review requirements
-
Status Checks
- Required checks that must pass before merging:
- Test (ubuntu-latest, amd64, stable)
- Test (ubuntu-latest, amd64, beta)
- Test (ubuntu-latest, amd64, 1.92)
- Security Audit
- Unused Dependencies
- Outdated Dependencies
- Build Documentation
- Require branches to be up to date before merging
- Required checks that must pass before merging:
-
Additional Protections
- Require conversation resolution before merging
- Prevent force pushes
- Prevent deletions
- Optional: Require linear history
- Optional: Require signed commits
GitHub Pages
- Build Type: GitHub Actions (not branch-based)
- Source: Automatically deployed from workflow
Security
- Vulnerability Alerts: Enabled
- Automated Security Fixes: Enabled (Dependabot)
Enforcement Workflow
The .github/workflows/enforce-repo-settings.yml workflow automatically applies settings when:
- Changes are pushed to the
mainbranch that modify files in.github/ - The workflow is manually triggered via
workflow_dispatch
Workflow Steps
- Checkout: Retrieves the repository code
- Read Settings: Validates that
.github/repo-settings.ymlexists - Install Tools: Installs
yqfor YAML parsing - Apply Settings: Uses GitHub API to update:
- Repository metadata and features
- Repository topics
- Branch protection rules
- Security settings
- Verify: Confirms settings were applied correctly
Making Changes
To modify repository settings:
- Edit
.github/repo-settings.ymlwith your desired changes - Create a pull request
- After the PR is merged to
main, the workflow will automatically apply the new settings
Example: Change Required Approvals
branch_protection:
main:
required_pull_request_reviews:
required_approving_review_count: 2 # Changed from 1 to 2
Example: Add a New Required Status Check
branch_protection:
main:
required_status_checks:
contexts:
- "Test (ubuntu-latest, amd64, stable)"
- "My New Check" # Add your new check here
Permissions
The workflow uses the default GITHUB_TOKEN which has limited permissions. Some settings may require:
- Repository admin access
- A Personal Access Token (PAT) with
repoandadmin:repo_hookscopes
If the workflow fails with permission errors, consider:
- Using a PAT stored as a repository secret
- Granting additional permissions to the default token (if supported by GitHub)
- Applying sensitive settings manually through the GitHub UI
Troubleshooting
Workflow Fails with Permission Errors
Issue: The workflow cannot apply certain settings due to insufficient permissions.
Solution:
- Some settings require repository admin access
- The default
GITHUB_TOKENmay not have sufficient permissions - Consider using a PAT or applying settings manually
Settings Not Applied
Issue: Changes to .github/repo-settings.yml don’t trigger the workflow.
Solution:
- Ensure changes are merged to the
mainbranch - Check that the workflow file exists at
.github/workflows/enforce-repo-settings.yml - Manually trigger the workflow using the “Actions” tab in GitHub
Status Checks Not Found
Issue: Branch protection complains that status checks don’t exist.
Solution:
- Status checks must run at least once before they can be required
- Create a test PR to trigger CI workflows
- After workflows run, the checks will be available
Manual Settings Application
To manually apply settings without pushing to main:
- Go to the repository’s “Actions” tab
- Select “Enforce Repository Settings” workflow
- Click “Run workflow”
- Select the
mainbranch - Click “Run workflow” button