ProxmoxVE/.github/workflows/check_and_update_json_date.yml
2025-01-15 10:21:44 +01:00

47 lines
1.4 KiB
YAML

name: Update Pull Request
on:
push:
branches-ignore: ["main"]
workflow_dispatch:
jobs:
update-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update JSON files
run: |
TODAY=$(date +%Y-%m-%d)
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
- name: Commit and push changes to PR branch
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
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