Skip to content

Commit 0001ece

Browse files
authored
chore: Add json yaml validate workflow (#6)
1 parent e8fef14 commit 0001ece

File tree

2 files changed

+108
-12
lines changed

2 files changed

+108
-12
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: JSON YAML Validate
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'web/list.json'
7+
- 'web/template.json'
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
14+
jobs:
15+
json-yaml-validate:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: validate example meta
21+
uses: GrantBirki/json-yaml-validate@v3.2.1
22+
with:
23+
comment: 'true'
24+
files:
25+
./web/list.json
26+
json_schema: ./web/template.json

web/template.json

Lines changed: 82 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,84 @@
11
{
2-
"caseTitle": "Example",
3-
"caseDesc": "A brief description of what this example demonstrates.",
4-
"tags": ["BSC", "opBNB"],
5-
"github": "GitHub repository link for this example.",
6-
"replit": "Replit repository link for this example.",
7-
"video": {
8-
"type": "ype of video source (e.g., youtube, file).",
9-
"link": "URL link to the video."
10-
},
11-
"guide": "Additional guide document link.",
12-
"otherLink": "Link to related resource or external page.",
13-
"imgUrl": "URL of the thumbnail image."
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Example Meta Schema",
4+
"description": "A JSON Schema for validating an array of example metadata objects.",
5+
"type": "array",
6+
"items": {
7+
"type": "object",
8+
"properties": {
9+
"caseTitle": {
10+
"type": "string",
11+
"description": "The title of the case/example."
12+
},
13+
"caseDesc": {
14+
"type": "string",
15+
"description": "A brief description of the case/example."
16+
},
17+
"tags": {
18+
"type": "array",
19+
"description": "An array of tags associated with the case.",
20+
"items": {
21+
"type": "string"
22+
}
23+
},
24+
"github": {
25+
"type": "string",
26+
"description": "GitHub repository link for the example."
27+
},
28+
"replit": {
29+
"type": "string",
30+
"description": "Replit repository link for the example."
31+
},
32+
"video": {
33+
"type": "object",
34+
"description": "Video metadata can be empty or if used must include both 'type' and 'link'.",
35+
"anyOf": [
36+
{
37+
"maxProperties": 0
38+
},
39+
{
40+
"required": [
41+
"type",
42+
"link"
43+
],
44+
"properties": {
45+
"type": {
46+
"type": "string",
47+
"description": "The video source type (e.g., youtube, file)."
48+
},
49+
"link": {
50+
"type": "string",
51+
"description": "The URL link to the video."
52+
}
53+
},
54+
"additionalProperties": false
55+
}
56+
]
57+
},
58+
"guide": {
59+
"type": "string",
60+
"description": "Link to additional guide resources."
61+
},
62+
"otherLink": {
63+
"type": "string",
64+
"description": "Link to a related resource or external page."
65+
},
66+
"imgUrl": {
67+
"type": "string",
68+
"description": "URL of the thumbnail image."
69+
}
70+
},
71+
"required": [
72+
"caseTitle",
73+
"caseDesc",
74+
"tags",
75+
"github",
76+
"replit",
77+
"video",
78+
"guide",
79+
"otherLink",
80+
"imgUrl"
81+
],
82+
"additionalProperties": false
83+
}
1484
}

0 commit comments

Comments
 (0)