mirror of
https://github.com/tiennm99/is-amazing.git
synced 2026-10-11 08:59:58 +00:00
55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
name: Check JSON on PR
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, synchronize]
|
|
|
|
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: Get All Changed Files
|
|
id: getfile
|
|
uses: jitterbit/get-changed-files@v1
|
|
- name: validate each changed JSON file
|
|
run: |
|
|
for file in ${{ steps.getfile.outputs.all }}
|
|
do
|
|
if [[ $file == 'domains/'*'.json' ]]; then
|
|
echo "Validating $file"
|
|
json-yaml-validate $file domain-schema.json # validate here
|
|
fi
|
|
done
|
|
- name: Comment on PR if Invalid
|
|
uses: actions/github-script@v5
|
|
if: ${{ steps.json-yaml-validate.outcome == 'failure' }}
|
|
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: ${{ steps.json-yaml-validate.outcome == '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!"
|
|
});
|