Update ambassadors.json to fix indentation (#793) #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate Ambassadors JSON | |
on: | |
push: | |
paths: | |
- 'programs/ambassadors/ambassadors.json' | |
pull_request: | |
paths: | |
- 'programs/ambassadors/ambassadors.json' | |
jobs: | |
validate-json: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install Dependencies | |
run: npm install ajv ajv-formats | |
- name: Validate ambassadors.json | |
run: | | |
node -e " | |
const Ajv = require('ajv/dist/2020'); | |
const addFormats = require('ajv-formats'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const ambassadorsDir = path.join(process.env.GITHUB_WORKSPACE, 'programs', 'ambassadors'); | |
const schemaPath = path.join(ambassadorsDir, 'ambassadors-schema.json'); | |
const dataPath = path.join(ambassadorsDir, 'ambassadors.json'); | |
try { | |
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf-8')); | |
const data = JSON.parse(fs.readFileSync(dataPath, 'utf-8')); | |
const ajv = new Ajv({ allErrors: true }); | |
addFormats(ajv); | |
const validate = ajv.compile(schema); | |
const valid = validate(data); | |
if (!valid) { | |
console.error('Validation failed:', validate.errors); | |
process.exit(1); | |
} else { | |
console.log('ambassadors.json is valid.'); | |
} | |
} catch (error) { | |
console.error('Error validating ambassadors.json:', error); | |
process.exit(1); | |
}" |