From 757b5bd267631fdc211f4635609fb915e7ffa5d6 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:21:26 +0100 Subject: [PATCH] Create update_json_date.sh1 --- .github/workflows/update_json_date.sh1 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/update_json_date.sh1 diff --git a/.github/workflows/update_json_date.sh1 b/.github/workflows/update_json_date.sh1 new file mode 100644 index 000000000..d07eab711 --- /dev/null +++ b/.github/workflows/update_json_date.sh1 @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Verzeichnis, das die JSON-Dateien enthält +json_dir="./json/*.json" + +current_date=$(date +"%Y-%m-%d") + +for json_file in $json_dir; do + if [[ -f "$json_file" ]]; then + current_json_date=$(jq -r '.date_created' "$json_file") + + if [[ "$current_json_date" != "$current_date" ]]; then + echo "Updating $json_file with date $current_date" + jq --arg date "$current_date" '.date_created = $date' "$json_file" > temp.json && mv temp.json "$json_file" + + git add "$json_file" + git commit -m "Update date_created to $current_date in $json_file" + else + echo "Date in $json_file is already up to date." + fi + fi +done +git push origin HEAD