-
Notifications
You must be signed in to change notification settings - Fork 53
38 lines (34 loc) · 1013 Bytes
/
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
38
name: Validate JSON on Pull Request
on:
pull_request:
types:
- opened
- synchronize
jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Validate JSON
run: |
# Check if the file exists
if [ -f ./UIRes/bannedplugin.json ]; then
# Validate the JSON file
DUPES=$(cat ./UIRes/bannedplugin.json | jq 'group_by(.Name)[] | {Name: .[0].Name, length: length} | select(.length > 1)')
echo "${#DUPES}"
echo "${DUPES}"
if [ $? -eq 0 ]; then
echo "JSON file is valid"
if [ "${#DUPES}" -gt 0 ]; then
echo "Duplicate entries found. Please correct them. ${DUPES}"
exit 1
fi
else
echo "JSON file is invalid"
exit 1
fi
else
echo "JSON file not found"
exit 1
fi