2025-01-15 09:40:38 +00:00
|
|
|
name: Update JSON Date and Push Changes
|
2025-01-10 12:36:20 +00:00
|
|
|
|
|
|
|
on:
|
2025-01-15 09:50:30 +00:00
|
|
|
pull_request:
|
2025-01-15 09:37:30 +00:00
|
|
|
branches:
|
|
|
|
- main
|
2025-01-10 12:36:20 +00:00
|
|
|
|
|
|
|
jobs:
|
2025-01-15 09:37:30 +00:00
|
|
|
update-json:
|
2025-01-10 12:36:20 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2025-01-15 09:40:38 +00:00
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
2025-01-15 09:50:30 +00:00
|
|
|
with:
|
2025-01-15 09:52:34 +00:00
|
|
|
ref: ${{ github.head_ref }}
|
2025-01-15 09:25:38 +00:00
|
|
|
|
2025-01-15 09:40:38 +00:00
|
|
|
- name: Set up authentication
|
|
|
|
env:
|
2025-01-15 09:50:30 +00:00
|
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
2025-01-15 09:40:38 +00:00
|
|
|
run: |
|
2025-01-15 09:50:30 +00:00
|
|
|
git config --global user.name "json-updater-bot"
|
|
|
|
git config --global user.email "json-updater-bot@users.noreply.github.com"
|
2025-01-15 09:40:38 +00:00
|
|
|
git config --global credential.helper 'store'
|
2025-01-15 09:50:30 +00:00
|
|
|
echo "https://json-updater-bot:$GH_TOKEN@github.com" > ~/.git-credentials
|
2025-01-15 09:40:38 +00:00
|
|
|
|
2025-01-15 09:50:30 +00:00
|
|
|
- name: Modify JSON files
|
2025-01-10 12:36:20 +00:00
|
|
|
run: |
|
2025-01-15 09:25:38 +00:00
|
|
|
TODAY=$(date -u +%Y-%m-%d)
|
2025-01-15 09:52:34 +00:00
|
|
|
# Filtern der geänderten Dateien im aktuellen PR im Vergleich zum Basisbranch
|
|
|
|
for json_file in $(git diff --name-only ${{ github.base_ref }}...${{ github.head_ref }} | grep '.json$'); do
|
2025-01-15 09:45:22 +00:00
|
|
|
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
|
2025-01-15 09:40:38 +00:00
|
|
|
done
|
2025-01-10 12:36:20 +00:00
|
|
|
|
2025-01-15 09:37:30 +00:00
|
|
|
- name: Commit changes
|
2025-01-10 12:36:20 +00:00
|
|
|
run: |
|
2025-01-15 09:40:38 +00:00
|
|
|
git add *.json
|
2025-01-15 09:45:22 +00:00
|
|
|
git commit -m "Update date_created to $TODAY"
|
2025-01-15 09:50:30 +00:00
|
|
|
git push origin ${{ github.head_ref }} # Push direkt in den PR-Branch
|