ProxmoxVE/.github/workflows/check_and_update_json_date.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

name: Check and Update JSON Date
on:
pull_request:
2025-01-10 13:20:42 +00:00
types: [synchronize, opened, reopened, edited]
paths:
- "json/*.json"
2025-01-15 08:58:13 +00:00
schedule:
2025-01-15 09:18:33 +00:00
- cron: "0 0,6,12,18 * * *" # Viermal täglich
2025-01-15 08:58:13 +00:00
workflow_dispatch:
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
2025-01-15 08:58:13 +00:00
with:
2025-01-15 09:18:33 +00:00
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: pip install jq
2025-01-10 13:20:42 +00:00
- name: Find and Update JSON files in /json folder
run: |
TODAY=$(date +%Y-%m-%d)
2025-01-10 13:20:42 +00:00
for file in $(git diff --diff-filter=A --name-only HEAD | grep '^json/.*\.json$'); do
if jq -e '.date_created' $file > /dev/null 2>&1; then
echo "Updating date_created in $file"
jq --arg date "$TODAY" '.date_created = $date' $file > temp.json && mv temp.json $file
git add $file
fi
done
2025-01-15 09:18:33 +00:00
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
run: |
2025-01-15 09:18:33 +00:00
git config user.name "GitHub Bot"
git config user.email "bot@github.com"
git commit -m "Update date_created in new JSON files" || echo "No changes to commit"
2025-01-15 09:18:33 +00:00
git push origin HEAD:${{ github.event.pull_request.head.ref }}