Skip to content

Approve Safe Changes

If the PR content only contains one or more of documentation, formatting changes, or tests, automatically approve the PR and apply a safe change label.

Approve safe changes

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