gitStream Quickstart Examples
This page contains common gitStream configurations that are a great place to get started with gitStream. For a more detailed list, check out the gitStream automation library.
How to use these examples.
These examples are all complete gitStream configuration files that you can download directly via the buttons below the examples and upload to the .cm
directory of your repo. Alternatively, you can copy and paste the individual automations, but make sure you include all required declarations and any related custom expressions from the configurations to ensure they work properly.
Suggest Code Reviewers
When someone applies a suggest-reviewers
label to a PR, use codeExperts to assign recommended reviewers and post a comment with the explainCodeExperts
automation action.
Suggest Code Reviewers
Request Changes for Deprecated Components
Request changes when a PR includes one or more deprecated components.
Change Deprecated Components
# -*- mode: yaml -*-
manifest:
version: 1.0
automations:
# Request changes when a PR includes deprecated components.
# This requires the `item` custom expression found at the bottom of this file.
{% for item in deprecated %}
# Automation names must be unique, so this adds an iterator index to each instance
review_deprecated_component_{{ item.old }}:
# Triggered when any of the modified files use a deprecated component
if:
- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
# Apply a deprecated-component label, request changes, and post a comment with an explanation.
run:
- action: add-label@v1
args:
label: 'deprecated-component'
color: '#FF0000'
- action: request-changes@v1
args:
comment: |
`{{ item.old }}` component is deprecated, use `{{ item.new }}` instead
{% endfor %}
# These are the deprecated files that are evaluated in catch_deprecated_components
deprecated:
- regex: r/oldAPI/
old: oldAPI
new: newAPI
- regex: r/anotherOldAPI/
old: anotherOldAPI
new: anotherNewAPI
Review Sensitive Files
Require sensitive files from a pre-determined list to be reviewed by a specific team.
Review Sensitive Files
# -*- mode: yaml -*-
manifest:
version: 1.0
automations:
# Assign special teams to review sensitive files.
# This requires the `sensitive` custom expression found at the bottom of this file.
review_sensitive_files:
# For all files listed in the sensitive custom expression.
if:
- {{ files | match(list=sensitive_files) | some }}
run:
# Add reviewers from the dev-leads team, and require two approvals
# Modify `my-organization/security` to match your organization.
- action: add-reviewers@v1
args:
reviewers: [my-organization/security]
- action: set-required-approvals@v1
args:
approvals: 2
- action: add-comment@v1
args:
comment: |
This PR affects one or more sensitive files and requires review from the security team.
# The `sensitive_file_review` automation requires this custom expression.
# Modify this list to suit your security needs.
sensitive_files:
- src/app/auth/
- src/app/routing/
- src/app/resources/
Approve Safe Changes
Automatically approve documentation, formatting, and test changes.
Approve Safe Changes
# -*- mode: yaml -*-
manifest:
version: 1.0
automations:
safe_changes:
# Triggered for any changes that only affect formatting, documentation, tests, or images
if:
- {{ is.formatting or is.docs or is.tests or is.image }}
# Apply a safe change label, approve the PR and explain why in a comment.
run:
- action: add-label@v1
args:
label: 'safe-change'
- action: approve@v1
- action: add-comment@v1
args:
comment: |
This PR is considered a safe change and has been automatically approved.
# These custom expressions are used in the safe_changes automation
is:
formatting: {{ source.diff.files | isFormattingChange }}
docs: {{ files | allDocs }}
tests: {{ files | allTests }}
image: {{ files | allImages }}
Provide Estimated Time to Review
Label all PRs with an estimated number of minutes it would take someone to review.
Provide Estimated Time to Review
# -*- mode: yaml -*-
manifest:
version: 1.0
automations:
estimated_time_to_review:
if:
- true
run:
- action: add-label@v1
args:
label: "{{ calc.etr }} min review"
color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
calc:
etr: {{ branch | estimatedReviewTime }}
colors:
red: 'b60205'
yellow: 'fbca04'
green: '0e8a16'
Label Missing Jira Info
Label PRs that don't reference a Jira ticket in the title or description. This uses regex to detect Jira ticket formats in the title (e.g. ABC-1234), and URLs to Jira tickets in the description.
Label Missing Jira Info
# -*- mode: yaml -*-
manifest:
version: 1.0
automations:
label_missing_jira_info:
# Triggered for PRs that don't have either a Jira ticket number in the title,
# or a link to a Jira ticket in the PR description.
if:
- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
run:
- action: add-label@v1
args:
label: "missing-jira"
color: 'F6443B'
has:
jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
More examples
Check out the gitStream automation library.
Click here to find a more extensive list of automation examples.