Skip to content

thiagodnf/yaml-schema-checker

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

A Github action for validating .yaml files using JSON schemas

GitHub Release GitHub contributors GitHub stars MIT Licence Open Source Love

Usage

You can now consume the action by referencing the available version.

uses: thiagodnf/yaml-schema-checker@v0.0.12
with:
  jsonSchemaFile: schemas/example.schema.json
  yamlFiles: folder/subfolder/**/*.yml

or you can use combine patterns and files as array:

uses: thiagodnf/yaml-schema-checker@v0.0.12
with:
  jsonSchemaFile: schemas/example.schema.json
  yamlFiles: |
    file_1.yml,file_2.yml # two files in the same line
    file_3.yml
    folder/subfolder/**/*.yml

This project uses glob to read files

Input

jsonSchemaFile

Required A JSON schema file following the format used at https://www.schemastore.org

yamlFiles

Required A list of files, directories, and wildcard patterns to be validated

filesSeparator

Optional Separator used to split the files input. Default is , (comma).

Outputs

validFiles

Comma separated list of files that passed

invalidFiles

Comma separated list of files that failed

Log

If you run this GitHub Actions, this is what the log information looks like:

Run thiagodnf/yaml-schema-checker@v0.0.12
Json Schema: schemas/example.schema.json
Yaml Files: folder/subfolder/**/*.yml
Found 4 file(s). Checking them:
❌ folder/subfolder/events/fake1.yml
    - instance.type is not one of enum values: conference,workshop,symposium
✅ folder/subfolder/events/fake2.yml
❌ folder/subfolder/events/fake3.yml
    - instance.id is not of a type(s) string
    - instance.type is not one of enum values: conference,workshop,symposium
❌ folder/subfolder/events/fake4.yml
    - instance.title is not of a type(s) string
Done. All files checked

Error: It was found 3 invalid file(s)

For Developers

Install the dependencies

npm install

Run the development enviroment

npm run dev

Questions or Suggestions

Feel free to access the discussions tab as you need

Contribute

Contributions to the this project are very welcome! We can't do this alone! Feel free to fork this project, work on it and then make a pull request.

License

Licensed under the MIT license.

Donate

I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, reach out to me if you want to do it.

Thanks!

❤️