You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-10Lines changed: 48 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -5,21 +5,29 @@
5
5
`Safe-settings`– an app to manage policy-as-code and apply repository settings to repositories across an organization.
6
6
7
7
1. In `safe-settings` all the settings are stored centrally in an `admin` repo within the organization. This is important. Unlike [Settings Probot](https://github.com/probot/settings), the settings files cannot be in individual repositories.
8
-
> **Note** It is possible to override this behavior and specify a custom repo instead of the `admin` repo.<br>
8
+
> **Note**
9
+
> It is possible to override this behavior and specify a custom repo instead of the `admin` repo.<br>
9
10
> This could be done by setting an `env` variable called `ADMIN_REPO`.
10
11
11
-
1. There are 3 levels at which the settings could be managed:
12
+
1. In `safe-settings` the settings can have 2 types of targets:
13
+
1.`org` - These settings are applied to the `org`. `Org`-targeted settings are defined in `.github/settings.yml` . Currently, only `rulesets` are supported as `org`-targeted settings.
14
+
2.`repo` - These settings are applied to `repos`
15
+
16
+
2. For The `repo`-targeted settings there can be at 3 levels at which the settings could be managed:
12
17
1. Org-level settings are defined in `.github/settings.yml`
13
-
> **Note** It is possible to override this behavior and specify a different filename for the `settings` yml repo.<br>
18
+
> **Note**
19
+
> It is possible to override this behavior and specify a different filename for the `settings` yml repo.<br>
14
20
> This could be done by setting an `env` variable called `SETTINGS_FILE_PATH`.
15
21
16
-
1.`Suborg` level settings. A `suborg` is an arbitrary collection of repos belonging to projects, business units, or teams. The `suborg` settings reside in a yaml file for each `suborg` in the `.github/suborgs` folder.
17
-
1.`Repo` level settings. They reside in a repo specific yaml in `.github/repos` folder
18
-
1. It is recommended to break the settings into org-level, suborg-level, and repo-level units. This will allow different teams to define and manage policies for their specific projects or business units. With `CODEOWNERS`, this will allow different people to be responsible for approving changes in different projects.
22
+
2.`Suborg` level settings. A `suborg` is an arbitrary collection of repos belonging to projects, business units, or teams. The `suborg` settings reside in a yaml file for each `suborg` in the `.github/suborgs` folder.
23
+
3.`Repo` level settings. They reside in a repo specific yaml in `.github/repos` folder
24
+
3. It is recommended to break the settings into org-level, suborg-level, and repo-level units. This will allow different teams to define and manage policies for their specific projects or business units. With `CODEOWNERS`, this will allow different people to be responsible for approving changes in different projects.
19
25
20
-
> **Note**`Suborg` and `Repo` level settings directory structure cannot be customized.
26
+
> **Note**
27
+
> `Suborg` and `Repo` level settings directory structure cannot be customized.
21
28
22
-
> **Note** The settings file must have a `.yml` extension only. `.yaml` extension is ignored, for now.
29
+
> **Note**
30
+
> The settings file must have a `.yml` extension only. `.yaml` extension is ignored, for now.
23
31
24
32
## How it works
25
33
@@ -36,6 +44,10 @@ The App listens to the following webhook events:
36
44
37
45
-**pull_request.opened**, **pull_request.reopened**, **check_suite.requested**: If the settings are changed, but it is not in the `default` branch, and there is an existing PR, the code will validate the settings changes by running safe-settings in `nop` mode and update the PR with the `dry-run` status.
38
46
47
+
-**repository_ruleset**: If the `ruleset` settings are modified in the UI manually, `safe-settings` will `sync` the settings to prevent any unauthorized changes.
48
+
49
+
-**member_change_events**: If a member is added or removed from a repository, `safe-settings` will `sync` the settings to prevent any unauthorized changes.
50
+
39
51
### Restricting `safe-settings` to specific repos
40
52
`safe-settings` can be turned on only to a subset of repos by specifying them in the runtime settings file, `deployment-settings.yml`.
41
53
If no file is specified, then the following repositories - `'admin', '.github', 'safe-settings'` are exempted by default.
@@ -45,7 +57,8 @@ To apply `safe-settings` __only__ to a specific list of repos, add them to the `
45
57
46
58
To ignore `safe-settings` for a specific list of repos, add them to the `restrictedRepos` section as `exclude` array.
47
59
48
-
> **Note** The `include` and `exclude` attributes support as well regular expressions.
60
+
> **Note**
61
+
> The `include` and `exclude` attributes support as well regular expressions.
49
62
50
63
### Custom rules
51
64
@@ -210,11 +223,36 @@ The App can be configured to apply the settings on a schedule. This could be a w
210
223
To periodically converge the settings to the configuration, set the `CRON` environment variable. This is based on [node-cron](https://www.npmjs.com/package/node-cron) and details on the possible values can be found [here](#env-variables).
211
224
212
225
### Pull Request Workflow
226
+
It is
213
227
`Safe-settings`explicitly looks in the `admin` repo in the organization for the settings files. The `admin` repo could be a restricted repository with `branch protections` and `codeowners`
214
228
215
229
In that set up, when changes happen to the settings files and there is a PR for merging the changes back to the `default` branch in the `admin` repo, `safe-settings` will run `checks` – which will run in **nop** mode and produce a report of the changes that would happen, including the API calls and the payload.
216
230
217
-
The checks will fail if `org-level` branch protections are overridden at the repo or suborg level with a lesser number of required approvers.
231
+
For e.g. If we have `override` validators that will fail if `org-level` branch protections are overridden at the repo or suborg level with a lesser number of required approvers, here is an screenshot of what users will see in the PR.
The app creates a `Check` at the end of its processing to indicate if there were any errors. The `Check` is called `safe-settings` and corrosponds to the latest commit on the `default` branch of the `admin` repo.
0 commit comments