From 0122e70b1d40d2ad6cc95a2cc654ff36cd54b024 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:35:53 +0100 Subject: [PATCH] Update update_json_date.yml --- .github/workflows/update_json_date.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update_json_date.yml b/.github/workflows/update_json_date.yml index f06792b5..9e193765 100644 --- a/.github/workflows/update_json_date.yml +++ b/.github/workflows/update_json_date.yml @@ -1,4 +1,4 @@ -name: Auto Update JSON-Dateien (nur neue Dateien) +name: Auto Update JSON-Dateien (new files only) on: push: @@ -22,33 +22,26 @@ jobs: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} - # Repository auschecken - name: Checkout repository uses: actions/checkout@v4 - # Git-Setup - name: Set up Git run: | git config --global user.name "GitHub Actions" git config --global user.email "github-actions[bot]@users.noreply.github.com" - # Finde neu hinzugefügte JSON-Dateien - name: Find newly added JSON files id: find_new_json run: | NEW_JSON_FILES=$(git log --diff-filter=A --name-only --pretty=format: -- json/*.json || true) if [[ -z "$NEW_JSON_FILES" ]]; then - echo "No new JSON files found." echo "CHANGED=false" >> $GITHUB_ENV else - echo "New JSON files detected:" - echo "$NEW_JSON_FILES" echo "$NEW_JSON_FILES" > new_json_files.txt echo "CHANGED=true" >> $GITHUB_ENV fi - # JSON-Dateien aktualisieren (nur wenn neue gefunden wurden) - name: Update date_created in new JSON files if: env.CHANGED == 'true' run: | @@ -60,7 +53,6 @@ jobs: DATE_IN_JSON=$(jq -r '.date_created' "$FILE" 2>/dev/null || echo "") if [[ "$DATE_IN_JSON" != "$TODAY" ]]; then - echo "Updating date_created in $FILE: $DATE_IN_JSON -> $TODAY" jq --arg date "$TODAY" '.date_created = $date' "$FILE" > tmp.json && mv tmp.json "$FILE" UPDATED=true fi @@ -73,7 +65,6 @@ jobs: echo "UPDATED=false" >> $GITHUB_ENV fi - # Falls Änderungen existieren: Commit und PR erstellen - name: Commit and create PR if changes exist if: env.UPDATED == 'true' run: | @@ -82,14 +73,13 @@ jobs: git checkout -b pr-update-json-dates git push origin pr-update-json-dates --force gh pr create --title "[core] Auto-update new JSON files" \ - --body "This PR is auto-generated by a GitHub Action to update the `date_created` field in newly created JSON files." \ + --body "This PR is auto-generated to update the `date_created` field in newly created JSON files." \ --head pr-update-json-dates \ --base main \ --label "automated pr" env: GH_TOKEN: ${{ steps.generate-token.outputs.token }} - # PR automatisch approven - name: Approve pull request if: env.UPDATED == 'true' env: @@ -100,7 +90,6 @@ jobs: gh pr review $PR_NUMBER --approve fi - # PR erneut approven, falls erforderlich - name: Re-approve pull request after update if: env.UPDATED == 'true' env: @@ -111,7 +100,6 @@ jobs: gh pr review $PR_NUMBER --approve fi - # Falls keine Änderungen erkannt wurden - name: No changes detected if: env.UPDATED == 'false' run: echo "No new JSON files needed an update. Workflow completed successfully."