This action converts a JSON string to a CSV string.
Create a workflow (eg: .github/workflows/csv.yml
). See Creating a Workflow file.
Note
The output of this action might exceed the maximum size of inputs/outputs. In that case leverage the generated artifacts.
name: JSON to CSV
on:
workflow_dispatch:
jobs:
run:
name: Run Action
runs-on: ubuntu-latest
steps:
- uses: austenstone/json-to-csv@main
id: csv
with:
json: '[{"name":"John","age":30,"city":"New York"},{"name":"Jane","age":25,"city":"New York"}]'
- run: echo "${{ steps.csv.outputs.csv }}"
You can output an artifact instead of a string. Use artifact-name
to specify the name of the artifact.
steps:
- uses: austenstone/json-to-csv@main
with:
json: '[{"name":"John","age":30,"city":"New York"},{"name":"Jane","age":25,"city":"New York"}]'
create-artifact: true
- uses: actions/download-artifact@v4
with:
name: ${{ steps.export.outputs.artifact-name }}
You can pass an artifact name to the action and it will use the JSON file/s in the artifact as input.
steps:
- uses: austenstone/json-to-csv@main
with:
json-artifact-name: ${{ steps.export.outputs.artifact-name }}
Various inputs are defined in action.yml
:
Name | Description | Default |
---|---|---|
json | The JSON to convert to CSV. | N/A |
json-artifact-name | The name of the artifact to use as input instead of json . |
N/A |
options | A JSON string of options https://www.npmjs.com/package/json-2-csv#json2csvarray-options--string | N/A |
create-artifact | Whether to create an artifact with the output. | false |
artifact-name | The name of the artifact to create. | json-to-csv |
Name | Description |
---|---|
csv | The csv output. |
artifact-name | The name of the artifact created. |
To get more help on the Actions see documentation.