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 JSON Date and Push Changes
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
update-json:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Generate a token
|
|
id: generate-token
|
|
uses: actions/create-github-app-token@v1
|
|
with:
|
|
app-id: ${{ secrets.JSON_APP_ID }}
|
|
private-key: ${{ secrets.JSON_APP_KEY }}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up authentication
|
|
env:
|
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --global credential.helper 'store'
|
|
echo "https://github-actions[bot]:$GH_TOKEN@github.com" > ~/.git-credentials
|
|
|
|
- name: Modify JSON file(s)
|
|
run: |
|
|
TODAY=$(date -u +%Y-%m-%d)
|
|
for json_file in $(find . -type f -name "*.json"); do
|
|
# Ensure the JSON structure is an object
|
|
if jq -e 'type == "object"' "$json_file" > /dev/null 2>&1; then
|
|
# Update the date_created field
|
|
jq --arg today "$TODAY" '.date_created = $today' "$json_file" > tmp.json && mv tmp.json "$json_file"
|
|
fi
|
|
done
|
|
|
|
- name: Commit changes
|
|
run: |
|
|
git add *.json
|
|
git commit -m "Update date_created to $TODAY"
|
|
git push origin main
|