Skip to content

Commit 0305bdb

Browse files
authored
Merge pull request #561 from linear-b/dependabot-example-to-triggers-reference
add dependabot example to triggers reference
2 parents a9f90ed + 421a303 commit 0305bdb

File tree

1 file changed

+83
-28
lines changed

1 file changed

+83
-28
lines changed

docs/execution-model.md

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,6 @@ The table below lists supported explicit triggers, categorized into those enable
6060
Explicit triggers are set independently per each automation block and can be configured at the file level, specific to each automation separately or in combination. If triggers are listed at the file level **and** specific automation, the automation will be triggered according to both triggers.
6161
If an automation block does not have explicit triggers configured, it will be triggered according to the default (implicit) triggers.
6262

63-
Usage example:
64-
65-
```yaml+jinja
66-
triggers:
67-
on:
68-
- pr_created
69-
- commit
70-
exclude:
71-
branch:
72-
- hotfix
73-
74-
automations:
75-
skip_github_action_label:
76-
on:
77-
- label_added
78-
if:
79-
- {{ pr.labels | match(term='experimental') | some }}
80-
run:
81-
- action: add-github-check@v1
82-
args:
83-
check_name: production-ci
84-
conclusion: skipped
85-
```
86-
8763
**Note on Matching:**
8864

8965
- 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.
@@ -111,7 +87,81 @@ automations:
11187
11288
### Examples
11389
114-
- Assign code expert reviewer when the PR is created and after each commit. Ignore branches with the string "hotfix" in them
90+
#### Dependabot and Renovate
91+
92+
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 trigger gitStream for Dependabot or Renovate unnecessarily, so you can configure the triggers to exclude the branch where Dependabot or Renovate PRs are created.
93+
94+
!!! warning "Required gitStream Plugins"
95+
This example requires you to install the [`extractDependabotVersionBump`](/filter-function-plugins/#extractdependabotversionbump) and [`compareSemver`](/filter-function-plugins/#comparesemver) plugins.
96+
97+
In your default automation file, you should exclude the branch where Dependabot or Renovate PRs are created:
98+
99+
```yaml+jinja title="gitstream.cm"
100+
manifest:
101+
version: 1.0
102+
103+
# Disable triggering when the PR is created by bots
104+
triggers:
105+
exclude:
106+
branch:
107+
- r/(Dependabot|dependabot|Renovate|renovate)/
108+
109+
# The default automations for developers below
110+
automations:
111+
estimated_time_to_review:
112+
if:
113+
- true
114+
run:
115+
- action: add-label@v1
116+
args:
117+
label: "{{ calc.etr }} min review"
118+
...
119+
```
120+
121+
And the other automations file is set to automate Dependabot PRs:
122+
123+
```yaml+jinja title="dependabot.cm"
124+
manifest:
125+
version: 1.0
126+
127+
triggers:
128+
include:
129+
branch:
130+
- r/(Dependabot|dependabot|Renovate|renovate)/
131+
132+
automations:
133+
bump_minor:
134+
if:
135+
- {{ bump == 'minor' }}
136+
- {{ branch.name | includes(term="dependabot") }}
137+
- {{ branch.author | includes(term="dependabot") }}
138+
run:
139+
- action: approve@v1
140+
- action: add-comment@v1
141+
args:
142+
comment: |
143+
Dependabot `minor` version bumps are approved automatically.
144+
145+
bump_patch:
146+
if:
147+
- {{ bump == 'patch' }}
148+
- {{ branch.name | includes(term="dependabot") }}
149+
- {{ branch.author | includes(term="dependabot") }}
150+
run:
151+
- action: approve@v1
152+
- action: merge@v1
153+
- action: add-comment@v1
154+
args:
155+
comment: |
156+
Dependabot `patch` version bumps are approved and merged automatically.
157+
158+
bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
159+
```
160+
161+
#### Assign code expert
162+
163+
Assign code expert reviewer when the PR is created and after each commit. Ignore branches with the string "hotfix" in them.
164+
115165
``` yaml+jinja
116166
triggers:
117167
on:
@@ -131,8 +181,10 @@ automations:
131181
reviewers: {{ repo | codeExperts(gt=10) }}
132182
```
133183

134-
- Explain code experts only if the label “suggest-reviewer” exists.
135-
The automation will be triggered after each commit and after each label addition. If the label “suggest-reviewer” exists, it will trigger the `explain-code-experts` automation
184+
#### Explain code experts
185+
186+
Explain code experts only if the label “suggest-reviewer” exists. The automation will be triggered after each commit and after each label addition. If the label “suggest-reviewer” exists, it will trigger the `explain-code-experts` automation.
187+
136188
```yaml+jinja
137189
triggers:
138190
on:
@@ -150,7 +202,10 @@ automations:
150202
gt: 10
151203
```
152204

153-
- Trigger only specific automations branch pattern A, and trigger other automation for all other branches except those that fit the pattern REGEX_PATTERN
205+
#### Branch regex pattern
206+
207+
Trigger only specific automations branch pattern A, and trigger other automation for all other branches except those that fit the pattern REGEX_PATTERN
208+
154209
```yaml+jinja
155210
# Automation in this file will trigger only for branch pattern REGEX_PATTERN
156211
triggers:

0 commit comments

Comments
 (0)