name: Update JSON Date and Push Changes on: pull_request: branches: - main jobs: update-json: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - name: Set up authentication env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | git config --global user.name "json-updater-bot" git config --global user.email "json-updater-bot@users.noreply.github.com" git config --global credential.helper 'store' echo "https://json-updater-bot:$GH_TOKEN@github.com" > ~/.git-credentials - name: Modify JSON files run: | TODAY=$(date -u +%Y-%m-%d) for json_file in $(find . -name "*.json"); do if jq -e 'type == "object"' "$json_file" > /dev/null 2>&1; then jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file" fi done - name: Commit changes run: | git add *.json git commit -m "Update date_created to $TODAY" || echo "No changes to commit" git push origin ${{ github.head_ref }} # Push direkt in den PR-Branch