refactor: to node action (#47)
CD / Release (push) Successful in 33s

Refactoring the action from a composite to Node action. This change improves security through pinning of packages as well as better test-ability and error handling.

Reviewed-on: #47
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #47.
This commit is contained in:
2026-06-27 14:00:15 +02:00
committed by t.behrendt
parent 3730a56a77
commit 30070f7f9c
20 changed files with 24600 additions and 174 deletions
+25
View File
@@ -0,0 +1,25 @@
import Ajv from "ajv";
export const validateJson = async (jsonFileContent: string): Promise<void> => {
const jsonObject = JSON.parse(jsonFileContent);
const schema = jsonObject["$schema"];
if (!schema) {
throw new Error("No schema found in JSON file.");
}
const schemaUrl = new URL(schema);
const schemaContent = await fetch(schemaUrl.toString());
const schemaText = await schemaContent.text();
const schemaObject = JSON.parse(schemaText);
const validator = new Ajv({
strict: false,
});
const validate = validator.compile(schemaObject);
const isValid = validate(jsonObject);
if (!isValid) {
throw new Error(`JSON file is not valid: ${validator.errorsText()}`);
}
};