Skip to content

Commit

Permalink
Add Github workflow to validate YAML schema
Browse files Browse the repository at this point in the history
This will allow us to ensure the YAML is well formatted in PRs. Note, we
would like to make `source` a required field, but the YAML file
currently fails this requirement.

NOTE: The github workflow currently warns about `Unexpected input(s)
'yaml-file-dir'. This is happening because of a bug that doesn't affect
the output. See:
lyubick/action-YAML-schema-validator#8
  • Loading branch information
sdemjanenko committed Jun 23, 2023
1 parent dc9626a commit 60d4843
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/validate-yaml-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Check schema
uses: lyubick/action-YAML-schema-validator@v2
with:
json-schema-file: schema.json
yaml-file-dir: accounts.yaml
yaml-json-file-dir: accounts.yaml
recursive: false
32 changes: 32 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"source": {
"anyOf": [
{ "type": "string" },
{
"type": "array",
"items": { "type": "string" },
"uniqueItems": true
}
]
},
"accounts": {
"type": "array",
"items": { "type": "string", "minLength": 12, "maxLength": 12 },
"uniqueItems": true
},
"type": {
"enum": ["aws"]
}
},
"required": ["name", "accounts"],
"additionalProperties": false
}
}

0 comments on commit 60d4843

Please sign in to comment.