Skip to content

Commit 3ddde45

Browse files
authored
Update filter-functions.md
1 parent 35e33f5 commit 3ddde45

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

docs/filter-functions.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,19 +915,29 @@ is_rookie: {{ repo | rankByGitBlame(lt=15) | match(term=branch.author) | some }}
915915

916916
#### `readFile`
917917

918-
Reads the contents of a file from the current branch or the "cm" folder and returns it as a string. This function only allows reading files from the "repo" and "cm" directories for security reasons.
918+
Reads the contents of a file from the current branch or the `cm` repo and returns it as a string.
919919

920920
<div class="filter-details" markdown=1>
921921

922922
| Argument | Usage | Type | Description |
923923
| -------- | ------ | ------ | ------------------------------------------------------------------- |
924-
| - | Input | String | The path to the file relative to the "repo" or "cm" directory |
925-
| type | Input | String | Optional. `txt` by default. The output type - either`txt` or `json` |
924+
| - | Input | String | The relative file path in the current repo. Prepend `../cm/` to get files from the `cm` repo |
925+
| type | Input | String | The content type. Optional, `txt` by default. Allowed options are `txt` or `json` |
926926
| - | Output | String | The contents of the file as a string |
927927
</div>
928928

929-
For example, to read a file named `config.yaml` from the "cm" directory:
929+
For example, add a comment with a file's content:
930930

931931
```yaml+jinja
932-
{{ "cm/config.yaml" | readFile }}
932+
automations:
933+
add_readme_comment:
934+
if:
935+
- true
936+
run:
937+
- action: add-comment@v1
938+
args:
939+
comment: |
940+
{{ README_CONTENT }}
941+
942+
README_CONTENT: {{ "txt" | readFile("./README.md") | dump }}
933943
```

0 commit comments

Comments
 (0)