Webhook Event Handlers
Safe Settings listens to the following webhook events defined inapp.yml:
branch_protection_rulecheck_runcheck_suitecreatecustom_property_valuesmemberpull_requestpushrepositoryrepository_rulesetteam
Event Triggers and Actions
Push Event
When it triggers: When code is pushed to the default branch of the admin repository. What it does:- Detects changes to
.github/settings.yml,.github/repos/*.yml, or.github/suborgs/*.yml - If
.github/settings.ymlis modified, triggers a full sync across all repositories - If specific repo or suborg configs are modified, syncs only those affected repositories
- Ignores pushes to non-default branches
index.js:250-288
Repository Created Event
When it triggers: When a new repository is created in the organization. What it does:- Automatically applies the appropriate settings to the new repository
- Combines org-level, suborg-level, and repo-specific configurations
- Ensures new repositories are immediately compliant with policies
index.js:615-620
Branch Protection Rule Event
When it triggers: When branch protection rules are created, edited, or deleted. What it does:- Checks if the change was made by a human user (not a bot)
- If modified by a human, syncs the repository to revert unauthorized changes
- Prevents manual circumvention of policy-defined branch protections
index.js:307-317
Repository Ruleset Event
When it triggers: When repository rulesets are modified. What it does:- Detects if the ruleset is organization-level or repository-level
- For org-level rulesets: triggers a full sync across all repositories
- For repo-level rulesets: syncs only the affected repository
- Ignores changes made by bots
index.js:331-350
Custom Property Values Event
When it triggers: When custom property values are updated on a repository. What it does:- Applies suborg configurations that are defined by custom properties
- Allows dynamic repository grouping based on property values
- Ignores changes made by bots
index.js:319-329
Member Change Events
Event types:member- Repository collaboratorsteam.added_to_repositoryteam.removed_from_repositoryteam.edited
- Sync repository settings to revert unauthorized permission changes
- Ensure team and collaborator access remains consistent with policy
- Only respond to human-initiated changes
index.js:352-369
Repository Edited Event
When it triggers: When repository settings are modified (description, homepage, topics, default branch, etc.). What it does:- Syncs the repository to restore policy-defined settings
- Prevents unauthorized changes to repository metadata
- Ignores bot-initiated changes
index.js:371-383
Repository Renamed Event
When it triggers: When a repository is renamed. What it does: By default, Safe Settings ignores repository renames. WhenBLOCK_REPO_RENAME_BY_HUMAN=true:
- If renamed by a human: Reverts the repository name to the original
- If renamed by a bot (not Safe Settings):
- Attempts to copy
<old-repo>.ymlto<new-repo>.ymlin the admin repo - Adds a comment indicating the rename occurred
- Skips if
<new-repo>.ymlalready exists
- Attempts to copy
- If renamed by Safe Settings: Allows the rename (when renaming via config file)
index.js:385-461
Repository Archived/Unarchived Events
When they trigger: When a repository is archived or unarchived. What they do:- Sync repository settings to ensure archive state matches policy
- Ignore bot-initiated changes
index.js:622-646
Create Event
When it triggers: When a branch or tag is created. What it does:- Checks if the created branch is the default branch
- If yes, syncs repository settings
- Ignores branch creation by bots
index.js:290-305
Pull Request Validation Workflow
When configuration changes are proposed via pull request in the admin repository, Safe Settings runs in dry-run mode (NOP mode).PR Validation Events
pull_request.openedpull_request.reopenedcheck_suite.requestedcheck_suite.rerequestedcheck_run.created
index.js:491-613
.github/settings.yml, repos, or suborgs)Webhook Event Flow
Bot Detection
Safe Settings includes logic to detect and ignore changes made by bots to prevent infinite loops:Webhook Configuration Requirements
To ensure Safe Settings receives all necessary events, your GitHub App must be configured with the following permissions inapp.yml:
| Permission | Access Level | Purpose |
|---|---|---|
administration | write | Manage repository settings |
checks | write | Create check runs for validation |
contents | write | Read config files and update repos |
members | write | Manage team and collaborator access |
pull_requests | write | Comment on PRs during validation |
organization_administration | write | Manage org-level settings |
repository_custom_properties | write | Read and write custom properties |
app.yml:33-116