mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-27 11:06:18 +00:00
Update check_and_update_json_date.yml
This commit is contained in:
parent
d186557488
commit
12a61a1d71
58
.github/workflows/check_and_update_json_date.yml
vendored
58
.github/workflows/check_and_update_json_date.yml
vendored
@ -1,33 +1,59 @@
|
|||||||
name: Update Date Created in PR
|
name: Update date_created in JSON files
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# Dieser Trigger wird für das Öffnen von PRs sowie für das Aktualisieren von offenen PRs verwendet
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
|
||||||
- '*.json'
|
|
||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
workflow_dispatch:
|
schedule:
|
||||||
|
# Dieser Trigger wird 4x am Tag ausgelöst, um sicherzustellen, dass das Datum aktualisiert wird
|
||||||
|
- cron: "0 0,6,12,18 * * *" # Führt alle 6 Stunden aus
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-date:
|
update-date:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout PR branch
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
|
|
||||||
- name: Install yq
|
- name: Install yq
|
||||||
run: |
|
run: |
|
||||||
curl -sSL https://github.com/mikefarah/yq/releases/download/v4.18.1/yq_linux_amd64 -o /usr/local/bin/yq
|
sudo apt-get update
|
||||||
chmod +x /usr/local/bin/yq
|
sudo apt-get install -y yq
|
||||||
|
|
||||||
- name: Update date_created in JSON
|
- name: Set the current date
|
||||||
run: |
|
id: set_date
|
||||||
TODAY=$(date -u +%Y-%m-%d)
|
run: echo "TODAY=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV
|
||||||
yq e '.date_created = strftime("%Y-%m-%d")' -i your_file.json
|
|
||||||
|
|
||||||
- name: Commit changes if necessary
|
- name: Check for changes in PR
|
||||||
run: |
|
run: |
|
||||||
git status
|
# Hole den PR-Branch
|
||||||
git diff --quiet || (git commit -m "Update date_created to $TODAY" && git push origin ${{ github.head_ref }})
|
PR_BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
|
||||||
|
git fetch origin $PR_BRANCH
|
||||||
|
|
||||||
|
# Liste alle JSON-Dateien im PR auf, die geändert wurden
|
||||||
|
CHANGED_JSON_FILES=$(git diff --name-only origin/main...$PR_BRANCH | grep '.json')
|
||||||
|
|
||||||
|
if [ -z "$CHANGED_JSON_FILES" ]; then
|
||||||
|
echo "No JSON files changed in this PR."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Gehe alle geänderten JSON-Dateien durch und aktualisiere das Datum
|
||||||
|
for file in $CHANGED_JSON_FILES; do
|
||||||
|
echo "Updating date_created in $file"
|
||||||
|
# Setze das aktuelle Datum
|
||||||
|
yq eval ".date_created = \"${{ env.TODAY }}\"" -i "$file"
|
||||||
|
git add "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Commit and push changes
|
||||||
|
run: |
|
||||||
|
# Prüfe, ob es Änderungen gibt und committe sie
|
||||||
|
git config user.name "json-updater-bot"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
git commit -m "Update date_created to ${{ env.TODAY }}" || echo "No changes to commit"
|
||||||
|
|
||||||
|
# Push zurück in den PR-Branch
|
||||||
|
git push origin $PR_BRANCH
|
||||||
|
Loading…
Reference in New Issue
Block a user