SebRollen / toml-action

14 stars 8 forks source link

manage array fields #16

Closed gpongelli closed 1 month ago

gpongelli commented 1 month ago

Hi, trying this action seems that TOML's array are extracted as string, having then no way to interact with it.

Is it possible to have an array object as "value" output ?

I've following situation:

pyproject.toml:

[tool.poetry]
    ...
    authors = ["Gabriele Pongelli <gpongelli@users.noreply.github.com>"]

github action :

      - name: get authors from toml
        uses: SebRollen/toml-action@v1.2.0
        id: read_toml_authors
        with:
          file: 'pyproject.toml'
          field: 'tool.poetry.authors'
...
       ${{ join(steps.read_toml_authors.outputs.value, ', ') }}

the join seems not working, I still have ["Gabriele Pongelli <gpongelli@users.noreply.github.com>"] as join's output instead of the expected "Gabriele Pongelli <gpongelli@users.noreply.github.com>" (square brackets should not be there after join, if the input is an array), so I think this action does not provide an array as output.

Can you please fix your action to handle this case ?

Thanks.

SebRollen commented 1 month ago

Hi @gpongelli

Not sure if this is possible. Outputs from an action are always converted to unicode strings, see https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs

In your case, the array is formatted using valid JSON, so you should be able to use fromJSON to parse it before calling join