File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,23 @@ jobs:
2828 - name : Check and modify JSON files
2929 run : |
3030 TODAY=$(date -u +%Y-%m-%d)
31- # Überprüfen, ob JSON-Dateien vorhanden sind und das Datum setzen
31+
32+ # Durchsuchen der Verzeichnisse nach JSON-Dateien
3233 for json_file in $(find . -name "*.json"); do
33- if jq -e 'type == "object"' "$json_file" > /dev/null 2>&1 ; then
34- current_date=$(jq -r '. date_created' "$json_file")
34+ if python3 -c "import json, sys; print(json.load(sys.stdin).get('date_created'))" < "$json_file" &> /dev/null; then
35+ current_date=$(python3 -c "import json, sys; data=json.load(sys.stdin); print(data.get(' date_created'))" < "$json_file")
3536 if [ "$current_date" != "$TODAY" ]; then
36- jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file"
37+ python3 -c "
38+ import json
39+ import sys
40+
41+ # Lade die JSON-Datei
42+ with open('$json_file', 'r+') as file :
43+ data = json.load(file)
44+ data['date_created'] = '$TODAY' # Setze das 'date_created' auf das heutige Datum
45+ file.seek(0)
46+ json.dump(data, file, indent=4)
47+ file.truncate() # Truncate file to remove any extra content"
3748 git add "$json_file"
3849 fi
3950 fi
You can’t perform that action at this time.
0 commit comments