Skip to content

Approve Tiny Changes

Approve single-line changes to a single file.

Approve tiny change

Conditions (all must be true):

  • If the PR contains a one-line change to a single file.

Automation Actions:

  • Apply a single-line label.
  • Approve the PR.
  • Post a comment explaining why the PR was approved.

name

# -*- mode: yaml -*-

manifest:
  version: 1.0

automations:
  approve_tiny_change:
    # Triggered for PRs that contain one file and one line.
    if:
      - {{ is.one_file and is.one_line }}
    run:
      - action: add-label@v1
        args:
          label: 'single-line'
      - action: approve@v1
      - action: add-comment@v1
        args:
          comment: |
            This PR has been approved because it is only a single line

changes:
  # Sum all the lines added in the PR
  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
  # Sum all the line removed in the PR
  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}

is:
  one_file: {{ files | length == 1 }}
  one_line: {{ changes.additions - changes.deletions <= 1 }}