| Crates.io | tree-sitter-gh-actions-expressions |
| lib.rs | tree-sitter-gh-actions-expressions |
| version | 0.5.1 |
| created_at | 2025-09-18 03:29:19.185829+00 |
| updated_at | 2025-10-15 23:14:45.244982+00 |
| description | Github Actions expressions grammar for tree-sitter |
| homepage | |
| repository | https://github.com/hdoc1509/tree-sitter-gh-actions-expressions |
| max_upload_size | |
| id | 1844210 |
| size | 164,092 |
Tree-sitter grammar for Github Actions expressions
[!IMPORTANT] ABI version:
15
gitignore
(optional): for hashFiles() functionjson (optional): for
fromJSON() functionyaml: injection to its
block_mapping_pair node. Check the yaml
injection section for more informationgh-actions.nvim: plugin that
integrates this grammar to your Neovim configurationWIP
WIP
You can get the built files from the release branch. If you
have specific instructions for your editor, PR's are welcome.
yaml parserUse the following query:
((block_mapping_pair
key: (flow_node) @_key
value: [
(block_node
(block_scalar) @_value)
(flow_node
[
(plain_scalar
(string_scalar) @_value)
(double_quote_scalar) @_value
])
]
(#match? @_value "${{")) @injection.content
(#is-gh-actions-file? "") ; NOTE: NEW PREDICATE
(#set! injection.language "gh_actions_expressions")
(#set! injection.include-children))
((block_mapping_pair
key: (flow_node) @_key
(#eq? @_key "if")
value: (flow_node
(plain_scalar
(string_scalar) @_value)
(#not-match? @_value "${{"))) @injection.content
(#is-gh-actions-file? "") ; NOTE: NEW PREDICATE
(#set! injection.language "gh_actions_expressions")
(#set! injection.include-children))
is-gh-actions-file predicateTo avoid injecting this grammar to files other than github actions, is
recommended to create a predicate named is-gh-actions-file.
[!NOTE] The creation of this directive varies for each editor
This predicate will be the responsible to allow injection to files that matches
the name pattern .github/workflows/*.ya?ml.
bash injections when using run key
To avoid these errors, is recommended to surround the expression within a
raw_string node, string with single quotes ', i.e.:
jobs:
dry-run:
name: dry-run
runs-on: ubuntu-latest
steps:
- name: dry-run
run: ./script.sh '${{ inputs.mode }}' --dry-run


Because variable expansion is done by using $ prefix, the ${{ and }} nodes
will cause an AST error. To avoid, this declare an auxiliary bash variable or an
environment variable:
jobs:
dry-run:
name: dry-run
runs-on: ubuntu-latest
steps:
- name: dry-run
run: |
auxiliary_var='${{ inputs.mode }}'
./script.sh "$MY_VAR and $MODE" --dry-run
./script.sh "$MY_VAR and $auxiliary_var" --dry-run
env:
MODE: ${{ inputs.mode }}

Thanks to @disrupted for creating tree-sitter-github-actions grammar, which is the base I used to create this grammar.