diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index 122b694..1b4d970 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -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