Update update_json_date.yml
Some checks failed
Auto Update .app-files / update-app-files (push) Waiting to run
Shellcheck / Shellcheck (push) Waiting to run
Create Changelog Pull Request / update-changelog-pull-request (push) Waiting to run
Frontend CI/CD / build (push) Waiting to run
Frontend CI/CD / deploy (push) Blocked by required conditions
Auto Update JSON-Date / update-json-dates (push) Has been cancelled

This commit is contained in:
CanbiZ 2025-02-11 10:58:53 +01:00 committed by GitHub
parent 133aa1a1f2
commit 0877e6a2f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
name: Auto Update JSON-Dateien (new files only) name: Auto Update JSON-Date
on: on:
push: push:
@ -25,30 +25,30 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Full history to check commit timestamps fetch-depth: 0 # Full history for proper detection
- name: Set up Git - name: Set up Git
run: | run: |
git config --global user.name "GitHub Actions" git config --global user.name "GitHub Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Find newly created JSON files from today - name: Find JSON files with incorrect date_created
id: find_new_json id: find_wrong_json
run: | run: |
TODAY=$(date -u +"%Y-%m-%d") TODAY=$(date -u +"%Y-%m-%d")
git fetch origin main --depth=1 > incorrect_json_files.txt
LATEST_COMMIT=$(git rev-parse origin/main)
> new_json_files.txt for FILE in json/*.json; do
if [[ -f "$FILE" ]]; then
DATE_IN_JSON=$(jq -r '.date_created' "$FILE" 2>/dev/null || echo "")
for FILE in $(git diff --diff-filter=A --name-only $LATEST_COMMIT -- json/); do if [[ "$DATE_IN_JSON" != "$TODAY" ]]; then
COMMIT_DATE=$(git log --format=%cI -- "$FILE" | tail -n 1 | cut -dT -f1) echo "$FILE" >> incorrect_json_files.txt
if [[ "$COMMIT_DATE" == "$TODAY" ]]; then fi
echo "$FILE" >> new_json_files.txt
fi fi
done done
if [[ -s new_json_files.txt ]]; then if [[ -s incorrect_json_files.txt ]]; then
echo "CHANGED=true" >> $GITHUB_ENV echo "CHANGED=true" >> $GITHUB_ENV
else else
echo "CHANGED=false" >> $GITHUB_ENV echo "CHANGED=false" >> $GITHUB_ENV
@ -57,21 +57,21 @@ jobs:
- name: Run update script - name: Run update script
if: env.CHANGED == 'true' if: env.CHANGED == 'true'
run: | run: |
chmod +x .github/scripts/update-json.sh chmod +x .github/workflows/scripts/update-json.sh
while read -r FILE; do while read -r FILE; do
.github/scripts/update-json.sh "$FILE" .github/workflows/scripts/update-json.sh "$FILE"
done < new_json_files.txt done < incorrect_json_files.txt
- name: Commit and create PR if changes exist - name: Commit and create PR if changes exist
if: env.CHANGED == 'true' if: env.CHANGED == 'true'
run: | run: |
git add json/*.json git add json/*.json
git commit -m "Auto-update date_created in new JSON files" git commit -m "Auto-update date_created in incorrect JSON files"
git checkout -b pr-update-json-dates git checkout -b pr-fix-json-dates
git push origin pr-update-json-dates --force git push origin pr-fix-json-dates --force
gh pr create --title "[core] Auto-update new JSON files" \ gh pr create --title "[core] Fix incorrect JSON date_created fields" \
--body "This PR is auto-generated to update the `date_created` field in newly created JSON files." \ --body "This PR is auto-generated to fix incorrect `date_created` fields in JSON files." \
--head pr-update-json-dates \ --head pr-fix-json-dates \
--base main \ --base main \
--label "automated pr" --label "automated pr"
env: env:
@ -82,7 +82,7 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
PR_NUMBER=$(gh pr list --head "pr-update-json-dates" --json number --jq '.[].number') PR_NUMBER=$(gh pr list --head "pr-fix-json-dates" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER --approve gh pr review $PR_NUMBER --approve
fi fi