ProxmoxVE/.github/workflows/check_and_update_json_date.yml

44 lines
1.3 KiB
YAML
Raw Normal View History

2025-01-15 09:40:38 +00:00
name: Update JSON Date and Push Changes
on:
2025-01-15 09:37:30 +00:00
push:
branches:
- main
jobs:
2025-01-15 09:37:30 +00:00
update-json:
runs-on: ubuntu-latest
steps:
2025-01-15 09:40:38 +00:00
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
2025-01-15 09:37:30 +00:00
with:
2025-01-15 09:40:38 +00:00
app-id: ${{ vars.JSON_APP_ID }}
private-key: ${{ secrets.JSON_APP_KEY }}
- name: Checkout code
uses: actions/checkout@v4
2025-01-15 09:25:38 +00:00
2025-01-15 09:40:38 +00:00
- 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: |
2025-01-15 09:25:38 +00:00
TODAY=$(date -u +%Y-%m-%d)
2025-01-15 09:40:38 +00:00
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
2025-01-15 09:37:30 +00:00
- name: Commit changes
run: |
2025-01-15 09:40:38 +00:00
git add *.json
git commit -m "Update date_created in JSON files to $TODAY"
2025-01-15 09:37:30 +00:00
git push origin main