Skip to content

Commit 61567a6

Browse files
authored
Update update_json_date.yml
1 parent e23137e commit 61567a6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

.github/workflows/update_json_date.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Auto Update JSON-Dates
1+
name: Auto Update JSON-Dateien (new files only)
22

33
on:
44
push:
@@ -25,7 +25,7 @@ jobs:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
2727
with:
28-
fetch-depth: 10 # Fetch at least 2 commits to compare changes
28+
fetch-depth: 0 # Fetch full history to check commit timestamps
2929

3030
- name: Set up Git
3131
run: |
@@ -36,27 +36,27 @@ jobs:
3636
id: find_new_json
3737
run: |
3838
TODAY=$(date -u +"%Y-%m-%d")
39+
> new_json_files.txt
3940
40-
git fetch origin main --depth=1
41+
for FILE in $(git ls-files --json | jq -r '.[]'); do
42+
COMMIT_DATE=$(git log --format=%cI -- "$FILE" | tail -n 1 | cut -dT -f1)
43+
if [[ "$COMMIT_DATE" == "$TODAY" ]]; then
44+
echo "$FILE" >> new_json_files.txt
45+
fi
46+
done
4147
42-
NEW_JSON_FILES=$(git log --since="$TODAY 00:00:00" --diff-filter=A --name-only --pretty=format: origin/main -- json/*.json || true)
43-
44-
if [[ -z "$NEW_JSON_FILES" ]]; then
45-
echo "No new JSON files created today."
46-
echo "CHANGED=false" >> $GITHUB_ENV
47-
else
48-
echo "New JSON files detected today:"
49-
echo "$NEW_JSON_FILES"
50-
echo "$NEW_JSON_FILES" > new_json_files.txt
48+
if [[ -s new_json_files.txt ]]; then
5149
echo "CHANGED=true" >> $GITHUB_ENV
50+
else
51+
echo "CHANGED=false" >> $GITHUB_ENV
5252
fi
5353
5454
- name: Run update script
5555
if: env.CHANGED == 'true'
5656
run: |
57-
chmod +x .github/workflows/scripts/update-json.sh
57+
chmod +x .github/scripts/update-json.sh
5858
while read -r FILE; do
59-
.github/workflows/scripts/update-json.sh "$FILE"
59+
.github/scripts/update-json.sh "$FILE"
6060
done < new_json_files.txt
6161
6262
- name: Commit and create PR if changes exist

0 commit comments

Comments
 (0)