mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-30 20:40:15 +00:00
48 lines
1.4 KiB
YAML
48 lines
1.4 KiB
YAML
name: Update "date_created" in new JSON files
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update-date-created:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Checkout PR branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Identify new JSON files
|
|
id: new-json-files
|
|
run: |
|
|
BASE_BRANCH=$(jq -r '.base.ref' < "$GITHUB_EVENT_PATH")
|
|
git fetch origin $BASE_BRANCH
|
|
NEW_JSON_FILES=$(git diff --diff-filter=A --name-only origin/$BASE_BRANCH HEAD -- 'json/*.json')
|
|
echo "NEW_JSON_FILES=$NEW_JSON_FILES" >> $GITHUB_ENV
|
|
|
|
- name: Update date_created in new JSON files
|
|
if: env.NEW_JSON_FILES != ""
|
|
run: |
|
|
TODAY=$(date -u +%Y-%m-%d)
|
|
for file in $NEW_JSON_FILES; do
|
|
echo "Updating date_created in $file"
|
|
jq --arg date "$TODAY" '.date_created = $date' "$file" > temp.json && mv temp.json "$file"
|
|
done
|
|
|
|
- name: Commit and push changes
|
|
if: env.NEW_JSON_FILES != ""
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add $NEW_JSON_FILES
|
|
git commit -m "Update date_created in new JSON files"
|
|
git push origin HEAD:${{ github.head_ref }}
|