Skip to content

Create joabutt.json #34

Create joabutt.json

Create joabutt.json #34

Workflow file for this run

name: Check JSON on PR
on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'domains/**/*.json'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Dependencies
run: npm install ajv-cli
- name: Get list of changed domain files
id: file_changes
run: |
git fetch origin ${{ github.event.pull_request.base.ref }}
git diff --name-only FETCH_HEAD..${{ github.sha }} | { grep '^domains/.*\.json$' || true; } > changed_files.txt
cat changed_files.txt
- name: JSON Schema Validate
run: |
while read file; do
npx ajv-cli validate -s .github/workflows/domain-schema.json -d $file
done < changed_files.txt
continue-on-error: true
- name: Comment on PR if Invalid
if: ${{ failure() }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "❌ Your JSON file is invalid, please check the template again!"
});
- name: Comment on PR if Valid
if: ${{ success() }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "✅ Your JSON file is valid!"
});
- name: Fail Job
if: ${{ failure() }}
run: exit 1