mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	Update check_and_update_json_date.yml
This commit is contained in:
		
							
								
								
									
										28
									
								
								.github/workflows/check_and_update_json_date.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.github/workflows/check_and_update_json_date.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
name: Update JSON Date and Push Changes
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
  pull_request:
 | 
			
		||||
    branches:
 | 
			
		||||
      - main
 | 
			
		||||
 | 
			
		||||
@@ -10,32 +10,26 @@ jobs:
 | 
			
		||||
    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
 | 
			
		||||
        with:
 | 
			
		||||
          ref: ${{ github.head_ref }} 
 | 
			
		||||
 | 
			
		||||
      - name: Set up authentication
 | 
			
		||||
        env:
 | 
			
		||||
          GH_TOKEN: ${{ steps.generate-token.outputs.token }}
 | 
			
		||||
          GH_TOKEN: ${{ secrets.GH_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 user.name "json-updater-bot"
 | 
			
		||||
          git config --global user.email "json-updater-bot@users.noreply.github.com"
 | 
			
		||||
          git config --global credential.helper 'store'
 | 
			
		||||
          echo "https://github-actions[bot]:$GH_TOKEN@github.com" > ~/.git-credentials
 | 
			
		||||
          echo "https://json-updater-bot:$GH_TOKEN@github.com" > ~/.git-credentials
 | 
			
		||||
 | 
			
		||||
      - name: Modify JSON file(s)
 | 
			
		||||
      - name: Modify JSON files
 | 
			
		||||
        run: |
 | 
			
		||||
          TODAY=$(date -u +%Y-%m-%d)
 | 
			
		||||
          for json_file in $(find . -type f -name "*.json"); do
 | 
			
		||||
            # Ensure the JSON structure is an object
 | 
			
		||||
          # Filtern der geänderten Dateien im aktuellen PR
 | 
			
		||||
          for json_file in $(git diff --name-only origin/main...$GITHUB_SHA | grep '.json$'); do
 | 
			
		||||
            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
 | 
			
		||||
@@ -44,4 +38,4 @@ jobs:
 | 
			
		||||
        run: |
 | 
			
		||||
          git add *.json
 | 
			
		||||
          git commit -m "Update date_created to $TODAY"
 | 
			
		||||
          git push origin main
 | 
			
		||||
          git push origin ${{ github.head_ref }}  # Push direkt in den PR-Branch
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user