Update check_pr.yml

This commit is contained in:
Joab authored and GitHub committed 2023-12-27 22:29:44 +08:00
1 parent 3c6c09e569
commit e0db6643e4
1 file changed
+18 -3
+18 -3
View File
@@ -1,6 +1,7 @@
name: Check JSON on PR
on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'domains/**/*.json'
@@ -9,7 +10,7 @@ permissions:
pull-requests: write
issues: write
jobs:
jobs:
build:
runs-on: ubuntu-latest
steps:
@@ -17,7 +18,6 @@ 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
@@ -25,7 +25,7 @@ jobs:
base_dir: './domains'
json_schema: '.github/workflows/domain-schema.json'
continue-on-error: true
- name: Comment on PR
- name: Comment on PR if Invalid
if: ${{ steps.json-yaml-validate.outcome == 'failure' }}
uses: actions/github-script@v5
with:
@@ -37,3 +37,18 @@ 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' }}
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: ${{ steps.json-yaml-validate.outcome == 'failure' }}
run: exit 1