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: documentation/config_docs.md
+26-30Lines changed: 26 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,18 @@
1
-
# About
1
+
# Repository Configuration
2
2
3
-
Config file is where the variables affecting the behaviour of notabot are defined.
3
+
A repository configuration file specifies how notifications should be handled for a given repository. It should be at the root of your monorepo in the main branch. The bot will look for a `notabot.json` file by default, but you can change this behavior with the `--config` flag.
4
+
5
+
When the bot receives its first incoming GitHub notification, it will query the repository URL to retrieve its configuration file. For subsequent notifications, it will use the cached configuration unless an update is detected.
6
+
7
+
To update the configuration, simply edit the configuration file and push your changes to GitHub. The bot will detect and apply those changes to the configuration, and will be reflected in the next request onwards.
8
+
9
+
Refer [here](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads) for more information on GitHub event payload structure.
4
10
5
11
# Configuration values
6
12
7
13
**example**
8
14
```json
9
15
{
10
-
"offline": "github-api-cache",
11
16
"main_branch_name": "develop",
12
17
"status_rules": {
13
18
...
@@ -17,16 +22,13 @@ Config file is where the variables affecting the behaviour of notabot are define
17
22
},
18
23
"label_rules": {
19
24
...
20
-
},
21
-
"suppress_cancelled_events": true
25
+
}
22
26
}
23
27
```
24
28
25
29
| value | description | optional | default |
26
30
|-|-|-|-|
27
31
|`main_branch_name`| main branch used for the repo; filtering notifications about merges of main into other branches | Yes | - |
28
-
|`offline`| path to github api data when http calls are not allowed; used for testing | Yes | - |
29
-
|`suppress_cancelled_events`| supresses status cancelled events | Yes |`true`|
30
32
|`status_rules`| status rules config object | No | - |
31
33
|`label_rules`| label rules config object | No | - |
32
34
|`prefix_rules`| prefix rules config object | No | - |
@@ -68,11 +70,11 @@ A json object with fields of bools for each status type.
68
70
|`cancelled`| provide regex to ignore `failure` notifications with a description that matches it | Yes | - |
69
71
70
72
71
-
## Label Config
73
+
## Label Options
72
74
73
-
Label rules apply to PR and issues notifications.
75
+
**Label rules** apply to PR and issue notifications. If a payload matches multiple rules, they are all included.
74
76
75
-
**example**
77
+
**Example**
76
78
```json
77
79
"label_rules": {
78
80
"default_channel": "default",
@@ -81,21 +83,18 @@ Label rules apply to PR and issues notifications.
81
83
"allow": [
82
84
"backend"
83
85
],
84
-
"ignore": [],
85
86
"channel": "backend"
86
87
},
87
88
{
88
89
"allow": [
89
90
"a1"
90
91
],
91
-
"ignore": [],
92
92
"channel": "a1-bot"
93
93
},
94
94
{
95
95
"allow": [
96
96
"a3"
97
97
],
98
-
"ignore": [],
99
98
"channel": "a3"
100
99
},
101
100
{
@@ -113,24 +112,24 @@ Label rules apply to PR and issues notifications.
113
112
114
113
| value | description | optional | default |
115
114
|-|-|-|-|
116
-
|`default_channel`| default channel to notify if no rules match | Yes |no channels will be notified on default|
115
+
|`default_channel`| default channel to notify if no rules match | Yes |don't notify any channel|
117
116
|`rules`| list of `label_rule` objects | No | - |
118
117
119
118
### Label Rule
120
119
120
+
A **label rule** specifies whether or not a Slack channel should be notified, based on the labels present in the given payload. For each rule, `ignore` is a blacklist of labels that should not notify the rule's channel, and `allow` is a whitelist of labels that should. If a label exists in both lists, the `ignore` list takes precedence. If an empty `ignore` list is provided, nothing is ignored. If an empty `allow` list is provided, everything is allowed. Both are optional; if neither are provided, the rule will always generate a notification for its channel.
121
+
121
122
| value | description | optional | default |
122
123
|-|-|-|-|
123
-
|`allow`| whitelist of label values that match this rule; if list is empty it vacuously satisfies the rule | No | - |
124
-
|`ignore`| blacklist of label values; any labels matching will not match the rule | No | - |
125
-
|`channel`| channel to use as webhook if matching this label rule | No | - |
126
-
127
-
## Prefix Config
124
+
|`allow`| if notifications match any label in this list, they should be routed to the channel | Yes | all labels allowed if no list provided |
125
+
|`ignore`| if notifications match any label in this list, they shouldn't be routed to the channel (even if they match any allow labels) | Yes | - |
126
+
|`channel`| channel to use as webhook if the rule is matched | No | - |
128
127
129
-
Prefix rules apply to filenames. If a filename satisfies a prefix rule, the rule's channel will be notified.
128
+
## Prefix Options
130
129
131
-
The prefix config object is exactly the same as **Label Config** except its `rules` are list of `prefix_rule` objects.
130
+
**Prefix rules** apply to push, commit comment, and status notifications. If a filename satisfies a prefix rule, the rule's channel will be notified. If a filename matches multiple rules, only the one that is matched by the *longest prefix* is included.
132
131
133
-
**example**
132
+
**Example**
134
133
```json
135
134
"prefix_rules": {
136
135
"default_channel": "default",
@@ -139,31 +138,28 @@ The prefix config object is exactly the same as **Label Config** except its `rul
139
138
"allow": [
140
139
"backend/a1"
141
140
],
142
-
"ignore": [],
143
141
"channel": "a1"
144
142
},
145
143
{
146
144
"allow": [
147
145
"backend/a5",
148
146
"backend/a4"
149
147
],
150
-
"ignore": [],
151
148
"channel": "backend"
152
149
},
153
150
{
154
-
"allow": [],
155
-
"ignore": [],
156
151
"channel": "all-push-events"
157
152
}
158
153
]
159
154
},
160
155
```
161
156
162
-
163
157
### Prefix Rule
164
158
159
+
A **prefix rule** specifies whether or not a Slack channel should be notified, based on the filenames present in the commits associated with the given payload. The semantics for the `allow` and `ignore` fields are the same as those for label rules (see above).
160
+
165
161
| value | description | optional | default |
166
162
|-|-|-|-|
167
-
|`allow`|whitelist of strings that if prefixed in the filename matches the rule|No|-|
168
-
|`ignore`|blacklist of strings that if prefixed in the filename does not match the rule | No| - |
169
-
|`channel`| channel to use as webhook if matching this prefix rule| No | - |
163
+
|`allow`|if commit files match any prefix in this list, they should be routed to the channel|Yes|all prefixes allowed if no list provided|
164
+
|`ignore`|if commit files match any prefix in this list, they shouldn't be routed to the channel (even if they match any allow prefixes) | Yes| - |
165
+
|`channel`| channel to use as webhook if the rule is matched| No | - |
Copy file name to clipboardExpand all lines: documentation/secret_docs.md
+8-29Lines changed: 8 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
-
# About
1
+
# Secrets
2
2
3
-
Secret file is where sensitive information such as the urls used for webhooks and other tokens are stored.
3
+
A secrets file stores sensitive information. Unlike the repository configuration file, it should not be checked into the monorepo's version control. Instead, store it locally at a location accessible by the bot.
4
4
5
-
# Secret Values
5
+
# Options
6
+
7
+
**Example**
6
8
7
-
**example**
8
9
```json
9
10
{
10
11
"slack_hooks": [
@@ -42,36 +43,14 @@ Secret file is where sensitive information such as the urls used for webhooks an
42
43
43
44
| value | description | optional | default |
44
45
|-|-|-|-|
45
-
|`slack_hooks`| list of webhook config objects| No | - |
46
+
|`slack_hooks`| list of channel names (`channel`) and their corresponding webhook endpoint (`url`)| No | - |
46
47
|`gh_token`| specify to grant the bot access to private repositories; omit for public repositories | Yes | - |
47
48
|`gh_hook_token`| specify to ensure the bot only receives GitHub notifications from pre-approved repositories | Yes | - |
48
49
49
50
## `gh_token`
50
51
51
-
### Token generation
52
-
53
-
Some event notifications (e.g., status, commit comment) require a personal token to be addded to the configuration. To create a personal token, take the following steps:
54
-
1. Verify your email address, if needed.
55
-
1. In the upper-right corner of any page, click your profile photo, then click **Settings**.
56
-
1. In the left sidebar, click **Developer settings**.
57
-
1. In the left sidebar, click **Personal access tokens**.
58
-
1. Click **Generate new token**.
59
-
1. Give your token a descriptive name in the **Note** section.
60
-
1. Grant ***repo*** scope.
61
-
1. Click **Generate token**.
62
-
1. Copy the token to `secrets.json` file in a `gh_token` field.
63
-
64
-
For more detailed instructions on token generation, refer to https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line.
65
-
52
+
Some operations, such as fetching a config file from a private repository, or the commit corresponding to a commit comment event, require a personal access token. Refer [here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) for detailed instructions on token generation.
66
53
67
54
## `gh_hook_token`
68
-
For more information on `gh_hook_token` see [developer.github.com/webhooks/securing](https://developer.github.com/webhooks/securing/)
69
55
70
-
## Webhook Config
71
-
72
-
Channels that are defined in rules in config will be mapped to urls defined in the webhook
73
-
74
-
| value | description | optional | default |
75
-
|-|-|-|-|
76
-
|`url`| url to call to send the message | No | - |
77
-
|`channel`| name of the channel where the message will be posted as used in config | No | - |
56
+
Refer [here](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/securing-your-webhooks) for more information on securing webhooks with a token.
0 commit comments