name: Update JSON Date and Push Changes on: push: branches: - main jobs: update-json: runs-on: ubuntu-latest steps: - name: Generate a token id: generate-token uses: actions/create-github-app-token@v1 with: app-id: ${{ secrets.JSON_APP_ID }} private-key: ${{ secrets.JSON_APP_KEY }} - name: Checkout code uses: actions/checkout@v4 - name: Set up authentication env: GH_TOKEN: ${{ steps.generate-token.outputs.token }} run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global credential.helper 'store' echo "https://github-actions[bot]:$GH_TOKEN@github.com" > ~/.git-credentials - name: Modify JSON file(s) run: | TODAY=$(date -u +%Y-%m-%d) for json_file in $(find . -type f -name "*.json"); do jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file" done - name: Commit changes run: | git add *.json git commit -m "Update date_created in JSON files to $TODAY" git push origin main