diff --git a/.github/workflows/Validate Ambassadors JSON.yml b/.github/workflows/Validate Ambassadors JSON.yml new file mode 100644 index 00000000..2d9b1653 --- /dev/null +++ b/.github/workflows/Validate Ambassadors JSON.yml @@ -0,0 +1,53 @@ +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); + }" diff --git a/programs/ambassadors/ambassadors-schema.json b/programs/ambassadors/ambassadors-schema.json new file mode 100644 index 00000000..c883668e --- /dev/null +++ b/programs/ambassadors/ambassadors-schema.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "description": "Array of contributor profiles", + "items": { + "type": "object", + "description": "Contributor profile", + "properties": { + "name": { + "type": "string", + "description": "Full name of the contributor" + }, + "img": { + "type": "string", + "format": "uri", + "description": "URL to the contributor's profile image" + }, + "bio": { + "type": "string", + "description": "Brief biography of the contributor" + }, + "title": { + "type": "string", + "description": "Professional title of the contributor" + }, + "github": { + "type": "string", + "description": "GitHub profile URL of the contributor" + }, + "twitter": { + "type": "string", + "description": "Twitter profile URL of the contributor" + }, + "mastodon": { + "type": "string", + "description": "Mastodon profile URL of the contributor" + }, + "linkedin": { + "type": "string", + "description": "LinkedIn profile URL of the contributor" + }, + "company": { + "type": "string", + "description": "Company where the contributor works" + }, + "country": { + "type": "string", + "description": "Country where the contributor is based" + }, + "contributions": { + "type": "array", + "description": "List of contributions made by the contributor", + "items": { + "type": "object", + "description": "Details of a specific contribution", + "properties": { + "type": { + "type": "string", + "enum": ["article", "talk", "video", "other", "book", "paper", "initiative", "project", "working group"], + "description": "Type of the contribution" + }, + "title": { + "type": "string", + "description": "Title of the contribution" + }, + "date": { + "type": "object", + "description": "Date of the contribution", + "properties": { + "year": { + "type": "integer", + "minimum": 1900, + "maximum": 2100, + "description": "Year of the contribution" + }, + "month": { + "type": "string", + "enum": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + "description": "Month of the contribution" + } + }, + "required": ["year", "month"] + }, + "link": { + "type": "string", + "format": "uri", + "description": "URL link to the contribution" + } + }, + "required": ["type", "title", "date", "link"] + } + } + }, + "required": ["name", "img", "bio", "title", "github", "company", "country", "contributions"] + } +} diff --git a/programs/ambassadors/ambassadors.json b/programs/ambassadors/ambassadors.json index 29f32766..c7e186a5 100644 --- a/programs/ambassadors/ambassadors.json +++ b/programs/ambassadors/ambassadors.json @@ -1,24 +1,24 @@ [ - { - "name": "I am the first Ambassador", - "img": "https://avatars.githubusercontent.com/u/40007659?v=4", - "bio": "I am the first JSON Schema Ambassador. I work as Schema Designer in ACME since 2002 and I am the implementer of the Turbo Implementation.", - "title": "Schema Designer at ACME", - "github": "iamthefirst", - "twitter": "iamthefirst", - "linkedin": "iamthefirst", - "company": "ACME", - "country": "🇺🇸", - "contributions": [ - { - "type": "article", - "title": "Title of my first contribution", - "date": { - "year": 2024, - "month": "May" - }, - "link": "link-to-my-contribution" - } - ] - } + { + "name": "I am the first Ambassador", + "img": "https://avatars.githubusercontent.com/u/40007659?v=4", + "bio": "I am the first JSON Schema Ambassador. I work as Schema Designer in ACME since 2002 and I am the implementer of the Turbo Implementation.", + "title": "Schema Designer at ACME", + "github": "iamthefirst", + "twitter": "iamthefirst", + "linkedin": "iamthefirst", + "company": "ACME", + "country": "🇺🇸", + "contributions": [ + { + "type": "article", + "title": "Title of my first contribution", + "date": { + "year": 2024, + "month": "May" + }, + "link": "https://github.com/my-contri" + } + ] + } ] \ No newline at end of file