krs23 / generic-yaml-gitops

GitHub action for post YAML files as REST calls.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validate YAML

Github action to validate yaml files against a JSON schema

Usage

Validate your YAML files against a JSON structure by providing a schema path and a list of files.

- name: Validate YAML
  uses: brittonhayes/validate-yaml
  with:
    schemaPath: 'schema.json'
    files: |
      example/foo.yaml

Example JSON Schema

{
  "test": {
    "structure": {
      "myValue": "string",
      "myValue2": "string"
    }
  }
}

Example Valid YAML for this schema

---
test:
  structure:
    myValue: '1'
    myValue2: '2'

More Complex Schema

  • Use ? to indicate an optional field
  • Specify the preferred type with values like "string" or "number"
  • Replicate deeply nested structures in JSON to represent expected YAML
{
  "structure": {
    "school": {
      "description?": "string",
      "code": "number",
      "principal": {
        "name": "string"
      },
      "classRooms": [
        {
          "name": "string",
          "id": "number",
          "location?": {
            "floor": "string",
            "building": "string"
          }
        }
      ],
      "teachers": ["string"]
    }
  }
}

About

GitHub action for post YAML files as REST calls.

License:MIT License


Languages

Language:TypeScript 100.0%