ProxmoxVE/.github/workflows/check_and_update_json_date.yml
2025-01-15 10:37:30 +01:00

43 lines
1.1 KiB
YAML

name: Update JSON and Push Changes
on:
push:
branches:
- main
jobs:
update-json:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Authenticate with GitHub App
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.JSON_APP_ID }}
private_key: ${{ secrets.JSON_APP_KEY }}
- name: Modify JSON file
run: |
JSON_FILE="json/mailrise.json"
TODAY=$(date -u +%Y-%m-%d)
if [ -f "$JSON_FILE" ]; then
echo "Updating date_created in $JSON_FILE to $TODAY"
jq --arg today "$TODAY" '.date_created = $today' $JSON_FILE > tmp.json && mv tmp.json $JSON_FILE
else
echo "File $JSON_FILE does not exist."
exit 1
fi
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add json/mailrise.json
git commit -m "Update date_created in mailrise.json to $TODAY"
git push origin main