fabasoad / yaml-json-xml-converter-action

GitHub action that converts YAML/JSON/XML file formats interchangeably

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YAML/JSON/XML action (Deprecated)

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.

GitHub release (latest SemVer including pre-releases) Unit Tests Security Tests Total alerts Language grade: JavaScript Known Vulnerabilities Maintainability Test Coverage

Converts YAML/JSON/XML file formats interchangeably.

Inputs

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

Outputs

Name Required Description
data Yes Result in a format defined in to argument

Example usage

Prerequisites

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"]
}

Workflow configuration

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 }}"

Result

Result

Hint: If you define the same format for from and to parameters you can use this action to read the file 😉

About

GitHub action that converts YAML/JSON/XML file formats interchangeably

License:MIT License


Languages

Language:JavaScript 100.0%