From c94deb38728905d07f150550e4347e3e9974bf30 Mon Sep 17 00:00:00 2001 From: Joab <89288499+Joabutt@users.noreply.github.com> Date: Sat, 30 Dec 2023 01:01:18 +0800 Subject: [PATCH] Update check_pr.yml --- .github/workflows/check_pr.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index 2a91bbc..4ab32fb 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -2,9 +2,7 @@ name: Check JSON on PR on: pull_request_target: types: [opened, synchronize] - paths: - - 'domains/**/*.json' - + permissions: contents: read pull-requests: write @@ -17,14 +15,19 @@ jobs: - name: Checkout source code uses: actions/checkout@v2 with: - ref: ${{ github.event.pull_request.head.sha }} - - name: json-yaml-validate - id: json-yaml-validate - uses: GrantBirki/json-yaml-validate@v2.4.0 - with: - base_dir: './domains' - json_schema: '.github/workflows/domain-schema.json' - continue-on-error: true + ref: ${{ github.event.pull_request.head.sha }} + - name: Get list of changed files + id: files + uses: lots0logs/gh-action-get-changed-files@2.1.4 + - name: validate each changed JSON file + run: | + for file in ${{ steps.files.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 if: ${{ steps.json-yaml-validate.outcome == 'failure' }} uses: actions/github-script@v5 @@ -44,3 +47,8 @@ jobs: 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!" + });