DDWMISSI-1203-DEVELOP #775
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: Validate JSON | |
#on: | |
# push: | |
# branches: | |
# - main # Ou a branch que deseja monitorar | |
#jobs: | |
# validate-json: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v2 | |
# - name: Validate JSON | |
# run: | | |
# if jq -e .field_to_check $GITHUB_WORKSPACE/path/to/your/json.json > /dev/null; then | |
# echo "Field 'field_to_check' exists." | |
# else | |
# echo "Field 'field_to_check' does not exist." | |
# exit 1 | |
# fi | |
# | |
name: Validate JSON | |
on: [push, pull_request] | |
jobs: | |
validate-json: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Validate JSON files | |
run: | | |
# Encontra todos os arquivos JSON e os valida | |
find . -type f -name '*.json' -print0 | while IFS= read -r -d '' file; do | |
echo "Validating $file" | |
jq empty "$file" || { echo "Invalid JSON: $file"; exit 1; } | |
done |