Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/austenstone/json-to-csv
GitHub Action to Convert JSON to CSV
https://github.com/austenstone/json-to-csv
actions csv json
Last synced: 21 days ago
JSON representation
GitHub Action to Convert JSON to CSV
- Host: GitHub
- URL: https://github.com/austenstone/json-to-csv
- Owner: austenstone
- License: mit
- Created: 2024-01-31T14:50:38.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-29T06:44:58.000Z (7 months ago)
- Last Synced: 2024-10-10T21:18:10.256Z (about 1 month ago)
- Topics: actions, csv, json
- Language: TypeScript
- Homepage:
- Size: 4.26 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON to CSV Action
This action converts a JSON string to a CSV string.
## Usage
Create a workflow (eg: `.github/workflows/csv.yml`). See [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#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.#### Basic Usage
```yml
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 }}"
```
#### Output Artifact
You can output an artifact instead of a string. Use `artifact-name` to specify the name of the artifact.```yml
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 }}
```#### Input Artifact
You can pass an artifact name to the action and it will use the JSON file/s in the artifact as input.```yml
steps:
- uses: austenstone/json-to-csv@main
with:
json-artifact-name: ${{ steps.export.outputs.artifact-name }}
```## ➡️ Inputs
Various inputs are defined in [`action.yml`](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 |## ⬅️ Outputs
| Name | Description |
| --- | - |
| csv | The csv output. |
| artifact-name | The name of the artifact created. |## Further help
To get more help on the Actions see [documentation](https://docs.github.com/en/actions).