Create joabutt.json #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check JSON on PR | |
on: | |
pull_request_target: | |
types: [opened, synchronize] | |
paths: | |
- 'domains/**/*.json' | |
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: json-yaml-validate | |
id: json-yaml-validate | |
uses: GrantBirki/[email protected] | |
with: | |
base_dir: './domains' | |
json_schema: '.github/workflows/domain-schema.json' | |
continue-on-error: true | |
- name: Comment on PR if Invalid | |
if: ${{ steps.json-yaml-validate.outcome == 'failure' }} | |
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 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 |