This is the new PullApprove v3 open preview! Help us finalize the next major version of PullApprove. Back to PullApprove v2.

Conditions

Conditions are how you decide when a group should be asked to look at a PR. Often times, people will set this up based on specific filetypes or languages. The same data and syntax also powers the pullapprove_conditions and notification filters.

Things to know

  • Every condition in the list must be true to activate the group
  • If you need to "or" a condition, do it in a single list item with the word "or"
  • Conditions must be strings (almost always need to be surrounded by quotes to be proper YAML)

Under the hood, conditions are evaluated as Python. There is a specific set of functions that you can use and variables you have access to. This allows you to write flexible, powerful "if" statements while still being readable. Note that in Python, some operators are written as more readable words, such as "in", "not in", "and", and, "or".

Examples

conditions:
- "'bug' in labels"
- "'sig-*' in labels"
- "regex('.*/app') in labels"
- "'*.py' in files or '*.js' in files"
- "'*travis*' in statuses.succeeded"
- "base == 'master'"
- "base != default_branch"
- "not mergeable"
- "'WIP' in title"
- "created_at < date('3 days ago')"
- "'feature*' in head.ref"

Context reference

The following variables are directly available when writing conditions and templates. For variables that are custom objects, see their properties further down the page.

Don't see what you need? Let us know.

Property Type Note
all function

Return True if bool(x) is True for all values x in the iterable.

If the iterable is empty, return True.

any function

Return True if bool(x) is True for any x in the iterable.

If the iterable is empty, return False.

length function

Return the number of items in a container.

len function

Return the number of items in a container.

count function

Return the number of items in a container.

regex function
contains function

Uses either fnmatch or regex depending on the type of object.

contains_fnmatch function
contains_regex function
date function

Parses a date from a string using dateparser.

locked bool
merged_at datetime
created_at datetime
mergeable_state str
author_association str
milestone Milestone
requested_teams Teams
assignees Users
statuses Statuses
files Files
deletions int
diff_url str
author User
statuses_url str
closed_at datetime
commits int
url str
updated_at datetime
requested_reviewers Users
rebaseable bool
merged_by User
html_url str
review_comments_url str
additions int
merged bool
maintainer_can_modify bool
comments int
state str
commits_url str
base Branch
title str
changed_files int
comments_url str
review_comment_url str
number int
patch_url str
merge_commit_sha str
issue_url str
labels Labels
node_id str
assignee User
review_comments int
body str
head Branch
user User
mergeable bool
id int
groups Groups

Milestone

Property Type Note
closed_at datetime
closed_issues int
created_at datetime
creator User
description str
due_on datetime
html_url str
id int
labels_url str
node_id str
number int
open_issues int
state str
title str
updated_at datetime
url str

User

Property Type Note
avatar_url str
events_url str
followers_url str
following_url str
gists_url str
gravatar_id str
html_url str
id int
login str
node_id str
organizations_url str
received_events_url str
repos_url str
site_admin bool
starred_url str
subscriptions_url str
type str
url str
username str

Teams

Property Type Note
ids list of int
names list of str

Team

Property Type Note
description str
id int
members_url str
name str
node_id str
permission str
privacy str
repositories_url str
slug str
url str

Users

Property Type Note
usernames list of str

Statuses

Statuses are pulled from the most recent commit on the pull request. See the GitHub documentation for more information.

Property Type Note
contexts list of str
errored Statuses
failed Statuses
pending Statuses
succeeded Statuses
successful Statuses

Status

Property Type Note
avatar_url str
context str
created_at datetime
creator dict
description str
id int
node_id str
state str
target_url str
updated_at datetime
url str

Files

See the GitHub documentation for more information.

Property Type Note
added Files
filenames list of str
modified Files
removed Files

File

Property Type Note
additions int
blob_url str
changes int
contents_url str
deletions int
filename str
patch str
raw_url str
sha str
status str

Branch

Property Type Note
label str
ref str
repo Repo
sha str
user User

Repo

Property Type Note
archive_url str
archived bool
assignees_url str
blobs_url str
branches_url str
clone_url str
collaborators_url str
comments_url str
commits_url str
compare_url str
contents_url str
contributors_url str
created_at datetime
default_branch str
deployments_url str
description str
downloads_url str
events_url str
fork bool
forks int
forks_count int
forks_url str
full_name str
git_commits_url str
git_refs_url str
git_tags_url str
git_url str
has_downloads bool
has_issues bool
has_pages bool
has_projects bool
has_wiki bool
homepage str
hooks_url str
html_url str
id int
issue_comment_url str
issue_events_url str
issues_url str
keys_url str
labels_url str
language str
languages_url str
license str
merges_url str
milestones_url str
mirror_url str
name str
node_id str
notifications_url str
open_issues int
open_issues_count int
owner User
private bool
pulls_url str
pushed_at datetime
releases_url str
size int
ssh_url str
stargazers_count int
stargazers_url str
statuses_url str
subscribers_url str
subscription_url str
svn_url str
tags_url str
teams_url str
trees_url str
updated_at datetime
url str
watchers int
watchers_count int

Labels

Property Type Note
names list of str

Label

Property Type Note
color str
default bool
id int
name str
node_id str
url str

Groups

Groups is a list of Group objects with a few handy shortcuts.

Property Type Note
active Groups
approved Groups
inactive Groups
names list of str
passing Groups
pending Groups
rejected Groups

Group

A PullApprove review group

Property Type Note
conditions list
is_active bool
is_passing bool
name str
request int
request_order str
required int
state str
teams list
users list of str