1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 16:51:52 +00:00

Update update_json_date.yml

This commit is contained in:
CanbiZ 2025-01-16 16:04:54 +01:00 committed by GitHub
parent 15faa76b69
commit 6d4eb9c3ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,52 +7,42 @@ jobs:
list-files:
runs-on: ubuntu-latest
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
# Hier wird zunächst der base-Branch (z.B. 'main' oder 'master') ausgecheckt
ref: ${{ github.event.pull_request.base.ref }}
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Fetch PR changes
run: |
# Remote 'fork' zeigt auf das Repo des PR-Erstellers
- name: Fetch PR changes
run: |
git remote add fork https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
# Hole den Branch vom Fork und nenne ihn lokal 'pullreq'
git fetch fork ${{ github.event.pull_request.head.ref }}:pullreq
git checkout pullreq
- name: Update JSON
run: |
# Liste geänderte Dateien im PR auf
- name: Update JSON
id: changed-files
run: |
FILES=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename' | tr '\n' ' ')
echo "changed_files=${FILES}"
# Für jede geänderte Datei prüfen, ob es eine .json ist.
for FILE in $FILES; do
if [[ "$FILE" =~ /(.*)\.json ]]; then
NAME="${BASH_REMATCH[1]}"
else
echo "no new JSON in $FILE"
echo "no new JSON in ${FILES}"
continue
fi
JSON_FILE="json/${NAME}.json"
if [[ -f "$JSON_FILE" ]]; then
echo "Updating date_created in $JSON_FILE"
jq --arg date "$(date +%Y-%m-%d)" '.date_created = $date' "$JSON_FILE" > tmp.json && mv tmp.json "$JSON_FILE"
else
echo "JSON file ${JSON_FILE} not found"
echo "JSON file $FILES not found"
fi
done
# Git-Config und Commit
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Commit nur, wenn Änderungen stattgefunden haben
git diff --exit-code || git commit -am "Updating Dates in affected JSON files."
# WICHTIG: Upstream-Branch setzen und pushen
git push --set-upstream origin pullreq
env:
git push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}