Giter Site home page Giter Site logo

thalesraymond / data-format-converter-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabasoad/data-format-converter-action

0.0 1.0 0.0 64 KB

GitHub action that converts YAML / JSON / XML / PROPS data formats interchangeably

License: MIT License

data-format-converter-action's Introduction

Data format converter action

GitHub release (latest SemVer including pre-releases) Functional Tests

Converts data formats interchangeably. The following formats are supported: XML, YAML, JSON, PROPS.

Inputs

Name Required Description Possible values
input Yes Path to the file to be converted <Path>
from Yes Format of a data in input file json, xml, yaml, props
to Yes Format of a data as a result json, xml, yaml, props

Outputs

Name Required Description
output Yes Converted data is in a format defined in to argument

Examples

1. YAML to JSON

1.1. Initial data

docker-compose.yml is a file to be converted into JSON with the following content:

version: '3.7'
services:
  mongo:
    image: mongo:4.2.3-bionic
    networks:
      - test-network

networks:
  test-network:
    name: test-network
    driver: bridge

1.2. Workflow configuration

name: Convert

on: push

jobs:
  converter:
    name: Run converter
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: fabasoad/data-format-converter-action@main
        id: yaml2json
        with:
          input: 'docker-compose.yml'
          from: 'yaml'
          to: 'json'
      - name: Print result
        run: echo "${{ steps.yaml2json.outputs.output }}"

1.3. Result

{
  "version": 3.7,
  "services": {
    "mongo": {
      "image": "mongo:4.2.3-bionic",
      "networks": [
        "test-network"
      ]
    }
  },
  "networks": {
    "test-network": {
      "name": "test-network",
      "driver": "bridge"
    }
  }
}

2. XML to YAML

2.1. Initial data

person.xml is a file to be converted into YAML with the following content:

<person>
    <name>John Doe</name>
    <age>32</age>
    <hobbies>Music</hobbies>
    <hobbies>PC Games</hobbies>
</person>

2.2. Workflow configuration

name: Convert

on: push

jobs:
  converter:
    name: Run converter
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: fabasoad/data-format-converter-action@main
        id: xml2yaml
        with:
          input: 'person.xml'
          from: 'xml'
          to: 'yaml'
      - name: Print result
        run: echo "${{ steps.xml2yaml.outputs.output }}"

2.3. Result

person:
  name: John Doe
  age: 32
  hobbies:
    - Music
    - PC Games

FAQ

What if from and to are the same?

There will not be error or any exception in this case. Result will be read from input and returned as output.

What OS are supported? I need to understand what type of runners I can use.

The following OS are supported: macOS ARM64, macOS AMD64, Windows x86, Windows AMD64, Linux x86, Linux ARM, Linux ARM64, Linux AMD64.

If you find that some of these OS don't work please open an issue or PR with the fix. Thanks!

data-format-converter-action's People

Contributors

thalesraymond avatar fabasoad avatar yevhen-fabizhevskyi-wbyt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.