ProxmoxVE/.github/workflows/check_and_update_json_date.yml

33 lines
852 B
YAML
Raw Normal View History

2025-01-15 10:04:03 +00:00
name: Update Date Created in PR
on:
2025-01-15 09:50:30 +00:00
pull_request:
2025-01-15 10:04:03 +00:00
paths:
- '*.json'
types: [opened, synchronize]
jobs:
2025-01-15 10:04:03 +00:00
update-date:
runs-on: ubuntu-latest
2025-01-15 10:04:03 +00:00
steps:
2025-01-15 09:59:01 +00:00
- name: Checkout PR branch
2025-01-15 09:40:38 +00:00
uses: actions/checkout@v4
2025-01-15 09:50:30 +00:00
with:
2025-01-15 10:04:03 +00:00
ref: ${{ github.head_ref }}
2025-01-15 09:25:38 +00:00
2025-01-15 10:04:03 +00:00
- name: Install yq
2025-01-15 09:40:38 +00:00
run: |
2025-01-15 10:04:03 +00:00
curl -sSL https://github.com/mikefarah/yq/releases/download/v4.18.1/yq_linux_amd64 -o /usr/local/bin/yq
chmod +x /usr/local/bin/yq
2025-01-15 09:40:38 +00:00
2025-01-15 10:04:03 +00:00
- name: Update date_created in JSON
run: |
2025-01-15 09:25:38 +00:00
TODAY=$(date -u +%Y-%m-%d)
2025-01-15 10:04:03 +00:00
yq e '.date_created = strftime("%Y-%m-%d")' -i your_file.json
2025-01-15 09:59:01 +00:00
- name: Commit changes if necessary
run: |
2025-01-15 10:04:03 +00:00
git status
2025-01-15 09:59:01 +00:00
git diff --quiet || (git commit -m "Update date_created to $TODAY" && git push origin ${{ github.head_ref }})