Update check_pr.yml

This commit is contained in:
Joab authored and GitHub committed 2023-12-30 00:39:09 +08:00
1 parent 8929463b9c
commit 0cb0164049
1 file changed
+22 -9
+22 -9
View File
@@ -18,15 +18,26 @@ jobs:
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'
- 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$' > 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: ${{ steps.json-yaml-validate.outcome == 'failure' }}
if: ${{ failure() }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -37,8 +48,9 @@ jobs:
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' }}
if: ${{ success() }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -49,6 +61,7 @@ jobs:
repo: context.repo.repo,
body: "✅ Your JSON file is valid!"
});
- name: Fail Job
if: ${{ steps.json-yaml-validate.outcome == 'failure' }}
if: ${{ failure() }}
run: exit 1