This feature provides a centralized approach to managing the Safe-Settings Admin Repo, allowing Safe-Settings configurations to be sync'd across multiple ORGs.
This adds the hub‑and‑spoke synchronization capability to Safe Settings.
One central master admin repository (the hub) serves as the authoritative source of configuration ('Master' Admin Config Repo) which is automatically propagated to each organization’s admin repository (the spokes).
Note: When something changes in the 'Master' repo (the hub), only those changed files are copied to each affected ORG’s admin repo, so everything stays in sync.
graph TD
A0(PR Closed Event) --> A1(HUB Admin Repo)
A1(ORG Admin Repo) --> B(ORG Admin Repo)
A1(HUB Admin Repo) --> C(ORG Admin Repo)
A1(HUB Admin Repo) --> D(ORG Admin Repo)
Note: for the standard setup lets assume that Safe-Settings configuration on the Admin Config Repos (Spokes) are stored in
.github/
These are the basic steps to setup the Enterprise-Level Safe-Settings, using Hub-sync support.
Register the Safe-Settings App in your Enterprise (Enterprise App) or in your Organization.
For App "installation tragets" (Where can this GitHub App be installed?) Choose Any account
Install the Safe-Settings App in any Organzation that you would like Safe-Settings to manage.
Create the Org-Level Repo that is your dedicated Safe-Settings Config Repo and will hold all Safe-Settings configurations for the Org.
Choose any Organization where the Safe-Settings App is installed and create a 'Master' Safe-Settings Admin Config Repo.
The Repository requires a standard directory structure for storing the config data:
.github/
└─ safe-settings/
├── globals/
│ └── manifest.yml
└── organizations/
├── org1/
│ └── ...yml
└── org2/
└── ...ymlNotes:
- The
manifest.ymlis a required file, that defines rules for syncing Global Safe-Settings configurations. We will address the content format later. org1andorg2are just examples and should be replaced with the real names of the Orgs that you want to manage with the Hub-Sync.
The Hub-Sync feature supports two options
-
Organization Sync: Any settings file in the
organizations/<ORG>directory will be synced to the specific<ORG>(Spoke) Admin config Repo subfolder (eg.: /.github/). Only updated files are sync'd to the ORG admin config Repo (spokes). -
Global Sync: Any settings file in the
globals/directory will be synced to the specific<ORG>(Spoke) Admin config Repo subfolder (eg.: /.github/).⚠️ The actual sync operation is based on the rules defined in theglobals/manifest.yml. The rules provide fine grained control over the sync targets and sync strategy.
These two options only require that you provide the files you would like to sync, in the correct sub-directory.
The manifest.yml defines the sync rules for global settings distribution.
-
Sample
manifest.ymlrules: - name: global-defaults # specify the target ORG(s) targets: - "*" files: - "*.yml" # mergeStrategy: merge | overwrite | preserve # -------------------------------------------- # merge = use a PR to sync files # overwrite = sync all files to the target ORG(s) (no PR) mergeStrategy: merge - name: security-policies # specify the target ORG(s) targets: - "acme-*" - "foo-bar" files: - settings.yml mergeStrategy: overwrite # optional toggle, default true # enabled: false
- name: global-defaults
targets:
- "*"
files:
- "*.yml"
mergeStrategy: merge- Purpose: Sync all YAML files to all organizations, merging changes via PR.
- name: security-policies
targets:
- "acme-*"
- "foo-bar"
files:
- settings.yml
mergeStrategy: overwrite
enabled: false- Purpose: Overwrite
settings.ymlin specific organizations, but currently disabled.
The manifest.yml file defines synchronization rules for Safe-Settings hub-and-spoke configuration management. Each rule specifies which organizations and files to target, and how to handle synchronization.
rules:
- name: <string>
targets: [<string>, ...]
files: [<string>, ...]
mergeStrategy: <merge|overwrite|preserve>
enabled: <true|false> # optional
# ...additional fields as needed- Type: Array of objects
- Description: List of synchronization rules. Each rule controls how specific files are synced to target organizations.
- Type: String
- Description: Unique identifier for the rule. Used for reference and logging.
- Example:
global-defaults,security-policies
- Type: Array of strings
- Description: List of organization names or patterns to apply the rule to.
"*": All organizations"acme-*": Organizations with names starting withacme-"foo-bar": Specific organization
- Example:
targets: - "*" - "acme-*" - "foo-bar"
- Type: Array of strings
- Description: File patterns to sync. Supports wildcards.
"*.yml": All YAML files"settings.yml": Specific file
- Example:
files: - "*.yml" - "settings.yml"
- Type: String (
merge,overwrite,preserve) - Description: Determines how files are synced:
merge: use a PR to sync filesoverwrite: Sync all files, replacing existing ones (direct commit, no PR)
- Example:
mergeStrategy: merge
- Type: Boolean (optional)
- Description: Toggle to enable or disable the rule. Default is
true. - Example:
enabled: false
| Name | Purpose | Default |
|---|---|---|
SAFE_SETTINGS_HUB_REPO |
Repo for master safe-settings contents | admin-master |
SAFE_SETTINGS_HUB_ORG |
Organization that hold the Repo | admin-master-org |
SAFE_SETTINGS_HUB_PATH |
source folder | .github/safe-settings |
SAFE_SETTINGS_HUB_DIRECT_PUSH |
Use a PR or direct commit | false |
-
Sync the
Hub Admin Repochanges to aSafe-Settings Admin Repoin the same ORG as the Hub Admin Repo. -
Sync the
Hub Admin changesto aSafe-Settings Admin Repoin a different ORG. -
'Global'Hub Admin Repoupdates. Changes willapplied to all Organization
The following table summarizes the Safe Settings API endpoints:
| Endpoint | Method | Purpose | Example Usage |
|---|---|---|---|
/api/safe-settings/installation |
GET | Organization installation, repo, and sync status | Fetch org status |
/api/safe-settings/hub/content |
GET | List hub repo files/directories | List hub files |
/api/safe-settings/hub/content/* |
GET | Fetch specific file or directory from hub repo | Get file content |
/api/safe-settings/hub/import |
POST | Import settings from orgs into the hub | Import org settings |
/api/safe-settings/env |
GET | App environment/config variables | Get env vars |
Examples:
- Fetch org installation status:
GET /api/safe-settings/installation
- Import settings from orgs:
POST /api/safe-settings/hub/import Body: { "orgs": ["org1", "org2"] }
- List hub repo files:
GET /api/safe-settings/hub/content?ref=main&recursive=true
- Get environment variables:
GET /api/safe-settings/env