Skip to content

TOML 1.0.0 Action to Read or Edit Values using JSONPath and Output or Write the Results to Outputs or File.

License

Notifications You must be signed in to change notification settings

cssnr/toml-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Tag Major GitHub Tag Minor GitHub Release Version GitHub Dist Size Workflow Release Workflow Test Workflow Lint Quality Gate Status GitHub Repo Size GitHub Top Language GitHub Last Commit Codeberg Last Commit GitHub Contributors GitHub Discussions GitHub Forks GitHub Repo Stars GitHub Org Stars Discord Ko-fi

TOML Action

TOML Action

TOML 1.0.0 Action to Parse, Read or Edit Values using JSONPath and set the Results to Outputs or Write to a File.

This action was built from the ground up using active libraries. See the Comparison for more details.

Uses smol-toml for TOML 1.0.0 parsing and jsonpath-plus for JSONPath.

View Example TOML File
title = "TOML Example"

[project]
name = "toml-action"
dynamic = ["version"]
authors = [{ name="Shane" }]

Get a Value

- name: TOML Action
  id: toml
  uses: cssnr/toml-action@v1
  with:
    file: .github/test/test.toml
    path: $.project.authors[0].name

- name: Echo Value
  run: |
    echo "${{ steps.toml.outputs.value }}"

Results: Shane

Edit a Value

- name: TOML Action
  uses: cssnr/toml-action@v1
  with:
    file: .github/test/test.toml
    path: $.project.authors[0].name
    value: I Made This

- name: Cat File
  run: |
    cat ".github/test/test.toml"
Results: click to view
title = "TOML Example"

[project]
name = "toml-action"
dynamic = [ "version" ]

[[project.authors]]
name = "I Made This"

Note: the results are different from the source, but the structure is identical.

Parse a File

- name: TOML Action
  id: toml
  uses: cssnr/toml-action@v1
  with:
    file: .github/test/test.toml

- name: Echo Results
  run: |
    echo "name: ${{ fromJSON(steps.toml.outputs.data).project.name }}"
    echo "data: ${{ fromJSON(steps.toml.outputs.data) }}"

Results name: toml-action

Results data: click to view
{
  "title": "TOML Example",
  "project": {
    "name": "toml-action",
    "dynamic": ["version"],
    "authors": [
      {
        "name": "Shane"
      }
    ]
  }
}

See the Inputs for more options...

Features

  • Use JSONPath
  • Parse TOML File
  • Read TOML Value
  • Edit TOML Value
  • Write the Results
  • Output Parsed Value
  • Output JSON Results
  • Output TOML Results

Upcoming

  • Convert Input File/JSON/YAML to TOML
  • Add Input to Set the type for value

Tip

Please submit a Feature Request to let us know what you want to see...

Comparison

Most of these actions are forks/clones of each other and none of them support JSONPath or both Read and Write.

Repository Read Write Path TOML Version TOML Parser Stars Last Updated Repository Language
cssnr/toml-action 1.0.0 smol-toml Stars Fork Updated Language
SebRollen/toml-action 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
ciiiii/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
colt-1/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
rahulp959/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
kaachod/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
sandstromviktor/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language
dangdennis/toml-action 0.4.0 toml Stars Fork Updated Language
sebasptsch/toml-edit-action 1.0.0 smol-toml Stars Fork Updated Language
Larry-Le/toml-editor 1.0.0-rc.1 iarna/toml Stars Fork Updated Language

Inputs

Input Default Value Description of Input
file Required TOML File Path
path - JSONPath to Read or Edit
value - Value to Edit/Update
write true Write Updates to file
output file Write to a Different File

file

This is the TOML file path to process relative to the working directory.

path

A JSONPath key to read or edit.

Leaving this blank will only read the file and output the JSON/TOML results.

String key: $.key
Nested key: $.key.nested
Array key: $.key.nested[0]

value

Value to edit/update at the given path.

Note: All inputs are strings but value is parsed with JSON.parse() to a string, boolean or number.

Leaving this blank will only read the value from path and output the results.

write

Write the results with the value back to the file.

To write to a different file, set the output to the file path.

Default: true

output

To write the results to a different file set the path to the file here. Directories will be created as necessary.

Default: file

Outputs

Output Description
value Parsed Value
data JSON Data
toml TOML String

Note: All outputs are strings parsed with JSON.stringify().

- name: TOML Action
  id: toml
  uses: cssnr/toml-action@v1
  with:
    file: file.toml
    path: author.name

- name: Echo Outputs
  env:
    toml: ${{ steps.toml.outputs.toml }}
  run: |
    echo "value: ${{ steps.toml.outputs.value }}"
    echo "data: ${{ steps.toml.outputs.data }}"
    echo "toml: ${toml}"

Note: toml is first set as an env variable due to the way multi-line output is evaluated using ${{ }} in a run block.

Tags

The following rolling tags are maintained.

Version Tag Rolling Bugs Feat. Name Target Example
GitHub Tag Major Major vN.x.x vN
GitHub Tag Minor Minor vN.N.x vN.N
GitHub Release Micro vN.N.N vN.N.N

You can view the release notes for each version on the releases page.

The Major tag is recommended. It is the most up-to-date and always backwards compatible. Breaking changes would result in a Major version bump. At a minimum you should use a Minor tag.

Support

For general help or to request a feature, see:

If you are experiencing an issue/bug or getting unexpected results, you can:

For more information, see the CSSNR SUPPORT.md.

Contributing

If you would like to submit a PR, please review the CONTRIBUTING.md.

Please consider making a donation to support the development of this project and additional open source projects.

Ko-fi

Actions Tools

Additionally, you can support other GitHub Actions I have published:

❔ Unpublished Actions

These actions are not published on the Marketplace, but may be useful.


📝 Template Actions

These are basic action templates that I use for creating new actions.

Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.


For a full list of current projects visit: https://cssnr.github.io/

About

TOML 1.0.0 Action to Read or Edit Values using JSONPath and Output or Write the Results to Outputs or File.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project