mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-23 05:01:28 +01:00
Update update_json_date.yml
This commit is contained in:
parent
15faa76b69
commit
6d4eb9c3ee
36
.github/workflows/update_json_date.yml
vendored
36
.github/workflows/update_json_date.yml
vendored
@ -7,32 +7,27 @@ jobs:
|
|||||||
list-files:
|
list-files:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout base branch
|
- name: Checkout PR Branch
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# Hier wird zunächst der base-Branch (z.B. 'main' oder 'master') ausgecheckt
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
ref: ${{ github.event.pull_request.base.ref }}
|
|
||||||
|
|
||||||
- name: Fetch PR changes
|
- name: Fetch PR changes
|
||||||
run: |
|
run: |
|
||||||
# Remote 'fork' zeigt auf das Repo des PR-Erstellers
|
|
||||||
git remote add fork https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
|
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 fetch fork ${{ github.event.pull_request.head.ref }}:pullreq
|
||||||
git checkout pullreq
|
git checkout pullreq
|
||||||
|
|
||||||
- name: Update JSON
|
- name: Update JSON
|
||||||
run: |
|
id: changed-files
|
||||||
# Liste geänderte Dateien im PR auf
|
run: |
|
||||||
FILES=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename' | tr '\n' ' ')
|
FILES=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename' | tr '\n' ' ')
|
||||||
echo "changed_files=${FILES}"
|
echo "changed_files=${FILES}"
|
||||||
|
|
||||||
# Für jede geänderte Datei prüfen, ob es eine .json ist.
|
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
if [[ "$FILE" =~ /(.*)\.json ]]; then
|
if [[ "$FILE" =~ /(.*)\.json ]]; then
|
||||||
NAME="${BASH_REMATCH[1]}"
|
NAME="${BASH_REMATCH[1]}"
|
||||||
else
|
else
|
||||||
echo "no new JSON in $FILE"
|
echo "no new JSON in ${FILES}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -41,18 +36,13 @@ jobs:
|
|||||||
echo "Updating date_created in $JSON_FILE"
|
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"
|
jq --arg date "$(date +%Y-%m-%d)" '.date_created = $date' "$JSON_FILE" > tmp.json && mv tmp.json "$JSON_FILE"
|
||||||
else
|
else
|
||||||
echo "JSON file ${JSON_FILE} not found"
|
echo "JSON file $FILES not found"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Git-Config und Commit
|
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
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."
|
git diff --exit-code || git commit -am "Updating Dates in affected JSON files."
|
||||||
|
git push
|
||||||
# WICHTIG: Upstream-Branch setzen und pushen
|
env:
|
||||||
git push --set-upstream origin pullreq
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
Loading…
Reference in New Issue
Block a user