Skip to content

Commit 1183354

Browse files
authored
Document user filtering in execution model (#819)
Add support for user-based trigger filtering to control which users can trigger automations. This enables excluding bot accounts and restricting automations to specific team members. Changes include: - New `triggers.include.user` and `triggers.exclude.user` configuration - Updated matching rules and default behavior documentation - Added user filtering examples and common use cases - Refactored Dependabot/Renovate example to use user filtering instead of branch patterns - Reorganized trigger documentation with subsection headings for clarity
1 parent 06a364e commit 1183354

1 file changed

Lines changed: 107 additions & 12 deletions

File tree

docs/execution-model.md

Lines changed: 107 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Triggers can be defined globally at the file level or specifically for each auto
5353

5454
#### `triggers` section
5555

56-
The `triggers` section in gitStream gives you precise control over when automations execute. It allows you to define conditions based on pull request events using `include` and `exclude` lists to specify branch and repository patterns. These lists determine which branches or repositories trigger or bypass automation but do not affect the events initiating automations - implicit triggers remain active when using only `include` and `exclude`.
56+
The `triggers` section in gitStream gives you precise control over when automations execute. It allows you to define conditions based on pull request events using `include` and `exclude` lists to specify branch, repository, and user patterns. These lists determine which branches, repositories, or users trigger or bypass automation but do not affect the events initiating automations - implicit triggers remain active when using only `include` and `exclude`.
5757

5858
Additionally, the `on` keyword defines specific events that trigger automations. It can be added at the file level (under the `triggers` section) or within individual automations for greater customization. When `on` is used, it switches from implicit to explicit triggering mode, meaning only the specified events will trigger automations. Multiple triggers can be stacked, meaning gitStream will execute the automation for each matching triggering event, allowing flexibility in defining automation behavior
5959

@@ -65,8 +65,17 @@ Additionally, the `on` keyword defines specific events that trigger automations.
6565
| `triggers.exclude.branch` :fontawesome-brands-github: | [String or regex] | Branches that match will not trigger the automation. |
6666
| `triggers.include.repository` | [String or regex] | Repositories that match will trigger the automation. |
6767
| `triggers.exclude.repository` | [String or regex] | Repositories that match will not trigger the automation. |
68+
| `triggers.include.user` :fontawesome-brands-github: | [String or regex] | Users that match will trigger the automation. |
69+
| `triggers.exclude.user` :fontawesome-brands-github: | [String or regex] | Users that match will not trigger the automation. |
6870
</div>
6971

72+
!!! note "Default Behavior"
73+
74+
- Implicit triggers are the default behavior if the automation doesn't have explicit triggers configured.
75+
- The automation runs for all branches, repositories, and users if neither include nor exclude is specified.
76+
77+
##### Trigger Events :fontawesome-brands-github:
78+
7079
The table below lists supported explicit triggers, categorized into those enabled by default and those that require manual activation.
7180

7281
<div class="trigger-details" markdown=1>
@@ -94,15 +103,23 @@ If an automation block does not have the `on` parameter configured (explicit tri
94103
!!! Note
95104
The `on` parameter can be used within individual automation blocks, while `triggers.include` and `triggers.exclude` can only be defined at the file level.
96105

106+
##### Branch Filtering :fontawesome-brands-github:
107+
108+
Branch filtering allows you to control which branches can trigger automations based on branch name patterns.
109+
97110
**Note on Matching:**
98111

99-
- When using a `String` as the matching type, the values in `triggers.include.*` and `triggers.exclude.*` require exact matches. This means that the names of branches or repositories must exactly match the specified string to either trigger or prevent triggering the automation.
112+
- When using a `String` as the matching type, the values in `triggers.include.branch` and `triggers.exclude.branch` require exact matches. This means that the names of branches must exactly match the specified string to either trigger or prevent triggering the automation.
100113
- For more precise control, use a regular expression (regex) format: `r/REGEX_PATTERN/`.
101114

102-
**Default Behavior:**
115+
##### Repository Filtering
116+
117+
Repository filtering allows you to control which repositories can trigger automations based on repository name patterns.
103118

104-
- Implicit triggers are the default behavior if the automation doesn't have explicit triggers configured.
105-
- The automation runs for all branches and repositories if neither include nor exclude is specified.
119+
**Note on Matching:**
120+
121+
- When using a `String` as the matching type, the values in `triggers.include.repository` and `triggers.exclude.repository` require exact matches. This means that the names of repositories must exactly match the specified string to either trigger or prevent triggering the automation.
122+
- For more precise control, use a regular expression (regex) format: `r/REGEX_PATTERN/`.
106123

107124
**Exclude/Include prioritization**
108125

@@ -119,6 +136,30 @@ If an automation block does not have the `on` parameter configured (explicit tri
119136
- my_feature
120137
```
121138
139+
##### User Filtering :fontawesome-brands-github:
140+
141+
User filtering allows you to control which users can trigger automations, enabling you to exclude bot accounts or include only specific team members. This helps reduce noise from automated tools and optimize automation quota usage.
142+
143+
**User Identification:**
144+
The user is matched against the event actor:
145+
146+
- For commits: the commit author
147+
- For PR creation: the PR author
148+
- For label changes: the user who added/removed the label
149+
- For comments: the commenter
150+
- For approvals: the approver
151+
152+
**Common Use Cases:**
153+
154+
- **Exclude bots:** Prevent automations from running when triggered by SonarQube, Dependabot, Renovate, or security scanners
155+
- **Include specific users:** Run automations only for specific team members or service accounts
156+
- **Reduce noise:** Filter out automated tool activity that doesn't require gitStream processing
157+
158+
**Note on Matching:**
159+
160+
- When using a `String` as the matching type, the values in `triggers.include.user` and `triggers.exclude.user` require exact matches. This means that the names of users must exactly match the specified string to either trigger or prevent triggering the automation.
161+
- For more precise control, use a regular expression (regex) format: `r/REGEX_PATTERN/`.
162+
122163
## Action-Level Execution Control
123164
124165
gitStream provides intelligent action-level execution control that automatically skips certain actions based on the original triggering event. This feature helps reduce noise and ensures that AI-powered and code-related actions only execute when there are actual code changes, improving efficiency across all supported providers (GitLab, Bitbucket, and GitHub).
@@ -205,10 +246,10 @@ This allows developers to get AI feedback during the coding process before marki
205246

206247
#### Dependabot and Renovate
207248

208-
For example, you can have your normal automations that help developers with their PRs and a separate automation that automates Dependabot or Renovate version bumps. Both automations serve distinctly different purposes: the first helps your developers streamline their PRs, while the other reduces developers' toil by auto-approving version bumps. You will not want to unnecessarily trigger gitStream for Dependabot or Renovate, so you can configure the triggers to exclude the branch where Dependabot or Renovate PRs are created.
249+
For example, you can have your normal automations that help developers with their PRs and a separate automation that automates Dependabot or Renovate version bumps. Both automations serve distinctly different purposes: the first helps your developers streamline their PRs, while the other reduces developers' toil by auto-approving version bumps. You will not want to unnecessarily trigger gitStream for Dependabot or Renovate, so you can configure the triggers to exclude these bot users.
209250

210251

211-
In your default automation file, you should exclude the branch where Dependabot or Renovate PRs are created:
252+
In your default automation file, you should exclude bot users like Dependabot or Renovate:
212253

213254
```yaml+jinja title="gitstream.cm"
214255
manifest:
@@ -219,8 +260,10 @@ manifest:
219260
# (automations will still trigger on commits, PR creation, etc.)
220261
triggers:
221262
exclude:
222-
branch:
223-
- r/(Dependabot|dependabot|Renovate|renovate)/
263+
user:
264+
- dependabot[bot]
265+
- renovate[bot]
266+
- r/(bot|dependabot|renovate)/
224267
225268
# The default automations for developers below
226269
automations:
@@ -240,12 +283,13 @@ And the other automations file is set to automate Dependabot PRs:
240283
manifest:
241284
version: 1.0
242285
243-
# Note: triggers.include still allows implicit triggers
286+
# Note: triggers.include still allows implicit triggers
244287
# However, the automations below use 'on' which switches to explicit mode
245288
triggers:
246289
include:
247-
branch:
248-
- r/(Dependabot|dependabot|Renovate|renovate)/
290+
user:
291+
- dependabot[bot]
292+
- renovate[bot]
249293
250294
automations:
251295
bump_minor:
@@ -326,6 +370,57 @@ automations:
326370
gt: 10
327371
```
328372

373+
#### User Filtering Examples :fontawesome-brands-github:
374+
375+
Exclude specific bot users from triggering automations while allowing all other users:
376+
377+
```yaml+jinja title="exclude-bots.cm"
378+
manifest:
379+
version: 1.0
380+
381+
# Exclude bot users from triggering automations
382+
triggers:
383+
exclude:
384+
user:
385+
- sonar
386+
- dependabot[bot]
387+
- renovate[bot]
388+
- r/(bot|scanner)/
389+
390+
automations:
391+
review_requirements:
392+
if:
393+
- true
394+
run:
395+
- action: set-required-approvals@v1
396+
args:
397+
approvals: 2
398+
```
399+
400+
Include only specific team members for sensitive automations:
401+
402+
```yaml+jinja title="team-only.cm"
403+
manifest:
404+
version: 1.0
405+
406+
# Only allow specific team members to trigger these automations
407+
triggers:
408+
include:
409+
user:
410+
- john-doe
411+
- jane-smith
412+
- r/team-lead-.*/
413+
414+
automations:
415+
security_review:
416+
if:
417+
- {{ files | match(regex=r/\.(env|key|pem)$/) | some }}
418+
run:
419+
- action: add-label@v1
420+
args:
421+
label: security-review-required
422+
```
423+
329424
#### Branch regex pattern
330425

331426
Trigger only specific automations branch pattern A, and trigger other automation for all other branches except those that fit the pattern REGEX_PATTERN.

0 commit comments

Comments
 (0)