-
Notifications
You must be signed in to change notification settings - Fork 6
37 lines (29 loc) · 1.15 KB
/
validate-json.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Validate devices.json
on:
pull_request:
paths:
- 'devices.json'
jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Validate devices.json
run: |
# Install jq (a lightweight and flexible command-line JSON processor)
sudo apt-get install jq
# Validate the JSON file using jq
jq empty devices.json
continue-on-error: true
- name: Comment on PR if validation fails
if: failure()
run: |
COMMENT="Hey! It looks like the devices.json file is invalid. Please ensure the file is properly formatted. You can validate it using [jq](https://stedolan.github.io/jq/)."
# Get the pull request number
PR_NUMBER=$(jq --raw-output .pull_request.number < $GITHUB_EVENT_PATH)
# Comment on the PR using GitHub API
curl -s -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-X POST \
-d '{"body": "'"$COMMENT"'"}' \
"https://api.github.com/repos/${{github.repository}}/issues/$PR_NUMBER/comments"