From aa3a3997f07f0a0dc159dfeb2cf8feec5342c17b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:45:22 +0100 Subject: [PATCH] Update check_and_update_json_date.yml --- .github/workflows/check_and_update_json_date.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_and_update_json_date.yml b/.github/workflows/check_and_update_json_date.yml index bf690436..79171041 100644 --- a/.github/workflows/check_and_update_json_date.yml +++ b/.github/workflows/check_and_update_json_date.yml @@ -33,11 +33,15 @@ jobs: run: | TODAY=$(date -u +%Y-%m-%d) for json_file in $(find . -type f -name "*.json"); do - jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file" + # Ensure the JSON structure is an object + if jq -e 'type == "object"' "$json_file" > /dev/null 2>&1; then + # Update the date_created field + jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file" + fi done - name: Commit changes run: | git add *.json - git commit -m "Update date_created in JSON files to $TODAY" + git commit -m "Update date_created to $TODAY" git push origin main