Skip to content

update #2

update #2 #4

Workflow file for this run

name: Check JSON on PR
on:
pull_request:
paths:
- 'domains/**/*.json'
jobs:
check_json:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Check JSON
run: |
for jsonfile in $(find domains -name "*.json"); do
echo "\nProcessing ${jsonfile}"
if ! cat ${jsonfile} | jq empty; then
echo "Failed parsing ${jsonfile}"
exit 1
fi
REQUIRED_FIELDS=('subdomain' 'url' 'email')
for field in ${REQUIRED_FIELDS[@]}; do
if ! cat "${jsonfile}" | jq -e "has(\"${field}\")"; then
echo "${field} does not exist in ${jsonfile}"
exit 1
fi
done
TYPE=$(jq -r '.type // "CNAME"' ${jsonfile})
URL=$(jq -r '.url' ${jsonfile})
if [ ${TYPE} = "CNAME" ] || [ -z ${TYPE} ]; then
if echo ${URL} | grep -E '^https?://[^/]*/[^/]+'; then
echo "URL in ${jsonfile} must not contain subdirectories for CNAME records."
exit 1
fi
fi
done