You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`capture`](#capture)<br />Find and return the first occurrence of a regex in the input string | String |`regex`| String |
23
+
|[`capture`](#capture)<br />Find and return the first occurrence of a regex in the input string | String |`regex`| String |
24
24
|[`difference`](#difference)<br />Given two lists, keep only items that are in the 1st list but not in the 2nd. |[Objects]|`list`|[Objects]|
25
25
|[`every`](#every)<br />Checks whether all element in the list are `true`|[Bool]| - | Bool |
26
26
|[`filter`](#filter)<br />Reduce list of items into a list of same items that match the specified term |[String]<br />[Object]|`regex`, `term`, `list`, `attr`|[String]<br />[Object]|
@@ -32,32 +32,33 @@ The following functions are supported in addition to the built-in functions prov
32
32
|[`reject`](#reject)<br />Inverse of [`filter`](#filter), the result list contains non-matching items |[String]<br />[Object]|`regex`, `term`, `list`, `attr`|[String]<br />[Object]|
33
33
|[`some`](#some)<br />Checks whether at least one element in the list is `true`|[Bool]| - | Bool |
|[`allDocs`](#alldocs)<br />Checks the list includes only documents |[`files`](./context-variables.md#files)| - | Bool |
44
-
|[`allImages`](#allimages)<br />Checks the list includes only images |[`files`](./context-variables.md#files)| - | Bool |
45
-
|[`allTests`](#alltests)<br />Checks the list includes only tests |[`files`](./context-variables.md#files)| - | Bool |
46
-
|[`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
47
-
|[`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
48
-
|[`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
49
-
|[`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes |[`branch`](./context-variables.md#branch)| - | Integer |
50
-
|[`extensions`](#extensions)<br />Lists all the unique file extensions |[String]| - |[String]|
51
-
|[`extractJitFindings`](#extractjitfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the Jit scan |[`pr`](./context-variables.md#pr)| - | Object |
52
-
|[`extractSonarFindings`](#extractsonarfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the SonarCloud scan |[`pr`](./context-variables.md#pr)| - | Object |
53
-
|[`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
54
-
|[`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo |[`repo.contributors`](./context-variables.md#repo)| String | Bool |
55
-
|[`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed |[[`FileDiff`](./context-variables.md#filediff-structure)]| - | Bool |
56
-
|[`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
57
-
|[`matchDiffLines`](#matchdifflines)<br />Match every line in diff |[[`FileDiff`](./context-variables.md#filediff-structure)]|`regex`, `ignoreWhiteSpaces`|[Bool]|
58
-
|[`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
59
-
|[`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
|[`allDocs`](#alldocs)<br />Checks the list includes only documents |[`files`](./context-variables.md#files)| - | Bool |
45
+
|[`allImages`](#allimages)<br />Checks the list includes only images |[`files`](./context-variables.md#files)| - | Bool |
46
+
|[`allTests`](#alltests)<br />Checks the list includes only tests |[`files`](./context-variables.md#files)| - | Bool |
47
+
|[`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
48
+
|[`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
49
+
|[`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
50
+
|[`estimatedReviewTime`](#estimatedreviewtime)<br />Estimated review time in minutes |[`branch`](./context-variables.md#branch)| - | Integer |
51
+
|[`extensions`](#extensions)<br />Lists all the unique file extensions |[String]| - |[String]|
52
+
|[`extractJitFindings`](#extractjitfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the Jit scan |[`pr`](./context-variables.md#pr)| - | Object |
53
+
|[`extractSonarFindings`](#extractsonarfindings) :fontawesome-brands-github: <br />Get an object with a summary of the findings found by the SonarCloud scan |[`pr`](./context-variables.md#pr)| - | Object |
54
+
|[`explainRankByGitBlame`](#explainrankbygitblame)<br />Short markdown text explaining rankByGitBlame results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
55
+
|[`isFirstCommit`](#isfirstcommit)<br />Checks if its the author first commit in the repo |[`repo.contributors`](./context-variables.md#repo)| String | Bool |
56
+
|[`isFormattingChange`](#isformattingchange)<br />Checks that only formatting changed |[[`FileDiff`](./context-variables.md#filediff-structure)]| - | Bool |
57
+
|[`mapToEnum`](#maptoenum)<br />return the enum value matches to the input key | String | Enum object | Object |
58
+
|[`matchDiffLines`](#matchdifflines)<br />Match every line in diff |[[`FileDiff`](./context-variables.md#filediff-structure)]|`regex`, `ignoreWhiteSpaces`|[Bool]|
59
+
|[`rankByGitActivity`](#rankbygitactivity)<br />Get list of contributors based on `git-commit` activity |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
60
+
|[`rankByGitBlame`](#rankbygitblame)<br />Get list of contributors based on `git-blame` results |[`repo`](./context-variables.md#repo)|`gt`, `lt`|[String]|
61
+
|[`readFile`](#readfile)<br />Reads the contents of a file from the current branch or "cm" folder | String - The file path | String (optional) - the file type. `txt` or `json`| String |
61
62
</div>
62
63
63
64
### Named arguments
@@ -234,13 +235,15 @@ Return `true` for each element in the list that match the search term.
234
235
235
236
</div>
236
237
237
-
For example, to check if all code changes are in the `tests` directory:
238
+
Examples:
239
+
240
+
Check if all code changes are in the `tests` directory:
238
241
239
242
```yaml+jinja
240
243
{{ files | match(regex=r/tests\//) | every }}
241
244
```
242
245
243
-
For example, to check if there are code changes with specific function call:
246
+
Check if there are code changes with specific function call:
244
247
245
248
```yaml+jinja
246
249
{{ source.diff.files | match(attr='diff', term='myFunction') | some }}
@@ -280,13 +283,15 @@ Creates a shallow copy of a portion of a given list, filtered down to just the e
280
283
281
284
</div>
282
285
283
-
For example, check if all changes, but JavaScript files are in tests directory:
286
+
Examples:
287
+
288
+
Check if all changes, but JavaScript files are in tests directory:
284
289
285
290
```yaml+jinja
286
291
{{ files | reject(regex=r/\.js$/) | match(regex=r/tests\//') | every }}
287
292
```
288
293
289
-
For example, check if all changes except for `config.json` files are formatting:
294
+
Check if all changes except for `config.json` files are formatting:
| - | Input | String | The relative file path in the current repo. Prepend `../cm/` to get files from the `cm` repo |
929
+
|`output`| Input | String | The content type. Optional, `txt` by default. Allowed options are `txt` or `json`. When using `json`, the output will be returned as a stringified Object |
930
+
| - | Output | String | The contents of the file as a String. In case of `json` output, the result will be `JSON.stringified`|
931
+
</div>
932
+
933
+
Examples:
934
+
935
+
Add a comment with a file's content:
936
+
937
+
```yaml+jinja
938
+
automations:
939
+
add_readme_comment:
940
+
if:
941
+
- true
942
+
run:
943
+
- action: add-comment@v1
944
+
args:
945
+
comment: |
946
+
{{ README_CONTENT }}
947
+
948
+
README_CONTENT: {{ "./README.md" | readFile() }}
949
+
```
950
+
951
+
Read JSON configuration file from the `cm` repo and use some of the properties in a comment:
952
+
```
953
+
automations:
954
+
describe_teams:
955
+
if:
956
+
- {{ true }}
957
+
run:
958
+
- action: add-comment@v1
959
+
args:
960
+
comment: |
961
+
We have {{ TEAMS | length }} teams with {{ TEAMS.front.members | length + TEAMS.back.members | length }} members in total:
962
+
FrontEnd: include {{ TEAMS.front.members | length }} members
963
+
BackEnd: include {{ TEAMS.back.members | length }} members
0 commit comments