Skip to content

Script Functions

The Expr Language Definition is a great resource to learn more about the language

pull_request

pull_request.state_is(string...) -> boolean

Check if the pull_request state is any of the provided states

Valid options:

  • CLOSED - In closed state
  • MERGED - Pull Request has been merged
  • OPEN - Opened Pull Request
pull_request.state_is("MERGED")
pull_request.state_is("CLOSED", "MERGED")

pull_request.modified_files(string...) -> boolean

Returns wether any of the provided files patterns have been modified in the Pull Request.

The file patterns use the .gitignore format.

pull_request.modified_files("*.go", "docs/") == true

pull_request.modified_files_list(string...) -> []string

Returns an array of files matching the provided (optional) pattern thas has been modified in the Pull Request.

The file patterns use the .gitignore format.

pull_request.modified_files_list("*.go", "docs/") == ["example/file.go", "docs/index.md"]

pull_request.has_label(string) -> boolean

Returns wether any of the provided label exist on the Pull Request.

pull_request.labels = ["hello"]
pull_request.has_label("hello") == true
pull_request.has_label("world") == false

pull_request.has_no_label(string) -> boolean

Returns wether the Pull Request has the provided label or not.

pull_request.labels = ["hello"]
pull_request.has_no_label("hello") == false
pull_request.has_no_label("world") == true

Global

duration(string) -> duration

Returns the time.Duration value of the given string str.

Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d" and "w".

duration("1h").Seconds() == 3600

uniq([]string) -> []string

Returns a new array where all duplicate values has been removed.

(["hello", "world", "world"] | uniq) == ["hello", "world"]

filepath_dir

filepath_dir returns all but the last element of path, typically the path's directory. After dropping the final element,

Dir calls Clean on the path and trailing slashes are removed.

If the path is empty, filepath_dir returns ".". If the path consists entirely of separators, filepath_dir returns a single separator.

The returned path does not end in a separator unless it is the root directory.

filepath_dir("example/directory/file.go") == "example/directory"

limit_path_depth_to

limit_path_depth_to takes a path structure, and limits it to the configured maximum depth. Particularly useful when using generated labels from a directory structure, and want to to have a label naming scheme that only uses path of the path.

limit_path_depth_to("path1/path2/path3/path4", 2), == "path1/path2"
limit_path_depth_to("path1/path2", 3), == "path1/path2"