This repository was archived by the owner on May 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
80 lines (73 loc) · 2.43 KB
/
project-addition.yml
File metadata and controls
80 lines (73 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Validate Project Data
on:
pull_request:
paths:
- "data.json"
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install dependencies
run: npm install ajv
- name: Validate JSON
run: |
node -e "
const Ajv = require('ajv');
const ajv = new Ajv();
const schema = {
type: 'object',
required: ['projects'],
properties: {
projects: {
type: 'array',
items: {
type: 'object',
required: ['studentName', 'projectName', 'description', 'tags', 'githubLink', 'image'],
properties: {
id: { type: 'number' },
studentName: { type: 'string', minLength: 1 },
projectName: { type: 'string', minLength: 1 },
description: { type: 'string', maxLength: 100 },
tags: {
type: 'array',
items: { type: 'string' },
minItems: 1
},
projectLink: { type: 'string', format: 'uri' },
githubLink: { type: 'string', format: 'uri' },
image: {
type: 'string',
format: 'uri',
pattern: '\\.(jpg|jpeg|png|gif)$'
}
}
}
}
}
};
const data = require('./data.json');
const valid = ajv.validate(schema, data);
if (!valid) {
console.error('Validation errors:', ajv.errors);
process.exit(1);
}
"
- name: Check for duplicate projects
run: |
node -e "
const data = require('./data.json');
const projects = data.projects;
const names = new Set();
for (const project of projects) {
if (names.has(project.projectName)) {
console.error('Duplicate project name:', project.projectName);
process.exit(1);
}
names.add(project.projectName);
}
"