This GitHub action is deprecated and no longer maintained starting from
2022/10/21
. Please use Data Format Converter Action instead. It is faster, can be run on any OS and supports much more data formats than this one.
Converts YAML/JSON/XML file formats interchangeably.
Name | Required | Description | Possible values |
---|---|---|---|
path | Yes | Path to the file to be converted | <Path> |
from | Yes | Format of a file | json , xml , yaml |
to | Yes | Format of a file as a result | json , xml , yaml |
Name | Required | Description |
---|---|---|
data | Yes | Result in a format defined in to argument |
Let's imagine we need to transform yaml file into xml format and json file into yaml format.
docker-compose.yml
file that will be transformed into json file.
---
version: '3.7'
services:
mongo:
image: mongo:4.2.3-bionic
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: abc123
networks:
- test-network
networks:
test-network:
name: test-network
driver: bridge
person.json
file that will be transformed into yaml file.
{
"name": "John Doe",
"age": 32,
"hobbies": ["Music", "PC Games"]
}
name: Convert
on: push
jobs:
converter:
name: Run converter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: fabasoad/yaml-json-xml-converter-action@main
id: yaml2xml
with:
path: 'docker-compose.yml'
from: 'yaml'
to: 'xml'
- name: Print yaml2xml result
run: echo "${{ steps.yaml2xml.outputs.data }}"
- uses: fabasoad/yaml-json-xml-converter-action@main
id: json2yaml
with:
path: 'package.json'
from: 'json'
to: 'yaml'
- name: Print json2yaml result
run: echo "${{ steps.json2yaml.outputs.data }}"
Hint: If you define the same format for
from
andto
parameters you can use this action to read the file 😉