mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-28 19:46:17 +00:00
Update check_and_update_json_date.yml
This commit is contained in:
parent
e756c49e50
commit
dbfb72807a
63
.github/workflows/check_and_update_json_date.yml
vendored
63
.github/workflows/check_and_update_json_date.yml
vendored
@ -1,47 +1,42 @@
|
|||||||
name: Update "date_created" in new JSON files
|
name: Update JSON and Push Changes
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
types:
|
branches:
|
||||||
- opened
|
- main
|
||||||
- synchronize
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-date-created:
|
update-json:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout PR branch
|
- name: Check out repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Authenticate with GitHub App
|
||||||
|
uses: tibdex/github-app-token@v1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
app_id: ${{ secrets.JSON_APP_ID }}
|
||||||
|
private_key: ${{ secrets.JSON_APP_KEY }}
|
||||||
|
|
||||||
- name: Identify new JSON files
|
- name: Modify JSON file
|
||||||
id: new-json-files
|
|
||||||
run: |
|
|
||||||
BASE_BRANCH=$(jq -r '.base.ref' < "$GITHUB_EVENT_PATH")
|
|
||||||
git fetch origin $BASE_BRANCH
|
|
||||||
NEW_JSON_FILES=$(git diff --diff-filter=A --name-only origin/$BASE_BRANCH HEAD -- 'json/*.json')
|
|
||||||
echo "NEW_JSON_FILES=$NEW_JSON_FILES" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Update date_created in new JSON files
|
|
||||||
if: env.NEW_JSON_FILES != ""
|
|
||||||
run: |
|
run: |
|
||||||
|
JSON_FILE="json/mailrise.json"
|
||||||
TODAY=$(date -u +%Y-%m-%d)
|
TODAY=$(date -u +%Y-%m-%d)
|
||||||
for file in $NEW_JSON_FILES; do
|
|
||||||
echo "Updating date_created in $file"
|
|
||||||
jq --arg date "$TODAY" '.date_created = $date' "$file" > temp.json && mv temp.json "$file"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Commit and push changes
|
if [ -f "$JSON_FILE" ]; then
|
||||||
if: env.NEW_JSON_FILES != ""
|
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: |
|
run: |
|
||||||
git config --global user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git add $NEW_JSON_FILES
|
git add json/mailrise.json
|
||||||
git commit -m "Update date_created in new JSON files"
|
git commit -m "Update date_created in mailrise.json to $TODAY"
|
||||||
git push origin HEAD:${{ github.head_ref }}
|
git push origin main
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user