ProxmoxVE/.github/workflows/check_and_update_json_date.yml

47 lines
1.4 KiB
YAML
Raw Normal View History

2025-01-15 09:21:44 +00:00
name: Update Pull Request
on:
2025-01-15 09:21:44 +00:00
push:
branches-ignore: ["main"]
2025-01-15 08:58:13 +00:00
workflow_dispatch:
jobs:
2025-01-15 09:21:44 +00:00
update-pr:
runs-on: ubuntu-latest
2025-01-15 09:21:44 +00:00
permissions:
contents: write
pull-requests: write
steps:
2025-01-15 09:21:44 +00:00
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
2025-01-15 08:58:13 +00:00
with:
2025-01-15 09:21:44 +00:00
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
2025-01-15 09:21:44 +00:00
- name: Checkout code
uses: actions/checkout@v4
with:
2025-01-15 09:21:44 +00:00
fetch-depth: 0
2025-01-15 09:21:44 +00:00
- name: Update JSON files
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:21:44 +00:00
- name: Commit and push changes to PR branch
2025-01-15 09:18:33 +00:00
env:
2025-01-15 09:21:44 +00:00
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
2025-01-15 09:21:44 +00:00
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Update date_created in JSON files" || echo "No changes to commit"
git push origin HEAD:${{ github.event.pull_request.head.ref }} --force