Skip to content

Approve Safe Changes

Automatically approve PRs that change docs, tests, and other safe assets.

Approve safe changes

Configuration Description

Conditions (all must be true):

  • The PR only contains documentation, tests, or formatting changes.

Automation Actions:

  • Add a safe-change label
  • Approve the PR
  • Post a comment that explains that this is a safe change

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 }}

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.