mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	[gh] Update Changelog Workflow (#2621)
* Update Workflow * Update Workflow
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							bef3ccd164
						
					
				
				
					commit
					893bff1b59
				
			
							
								
								
									
										83
									
								
								.github/workflows/changelog-pr.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										83
									
								
								.github/workflows/changelog-pr.yml
									
									
									
									
										vendored
									
									
								
							@@ -30,7 +30,6 @@ jobs:
 | 
			
		||||
 | 
			
		||||
      - name: Get latest dates in changelog
 | 
			
		||||
        run: |
 | 
			
		||||
          # Extrahiere die neuesten zwei Daten aus dem Changelog
 | 
			
		||||
          DATES=$(grep -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | head -n 2 | awk '{print $2}')
 | 
			
		||||
 | 
			
		||||
          LATEST_DATE=$(echo "$DATES" | sed -n '1p')
 | 
			
		||||
@@ -55,7 +54,15 @@ jobs:
 | 
			
		||||
            const configPath = path.resolve(process.env.CONFIG_PATH);
 | 
			
		||||
            const fileContent = await fs.readFile(configPath, 'utf-8');
 | 
			
		||||
            const changelogConfig = JSON.parse(fileContent);
 | 
			
		||||
            const categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
 | 
			
		||||
 | 
			
		||||
            const categorizedPRs = changelogConfig.map(obj => ({
 | 
			
		||||
              ...obj,
 | 
			
		||||
              notes: [],
 | 
			
		||||
              subCategories: obj.subCategories ?? (obj.labels.includes("update script") ? [
 | 
			
		||||
                { title: "🐞 Bug Fixes", labels: ["bugfix"] },
 | 
			
		||||
                { title: "✨ Feature Updates", labels: ["feature"] }
 | 
			
		||||
              ] : [])
 | 
			
		||||
            }));
 | 
			
		||||
 | 
			
		||||
            const latestDateInChangelog = new Date(process.env.LATEST_DATE);
 | 
			
		||||
            latestDateInChangelog.setUTCHours(23, 59, 59, 999);
 | 
			
		||||
@@ -70,29 +77,33 @@ jobs:
 | 
			
		||||
              per_page: 100,
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            pulls.filter(pr => 
 | 
			
		||||
              pr.merged_at && 
 | 
			
		||||
              new Date(pr.merged_at) > latestDateInChangelog && 
 | 
			
		||||
              !pr.labels.some(label => ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()))
 | 
			
		||||
            pulls.filter(pr =>
 | 
			
		||||
            pr.merged_at &&
 | 
			
		||||
            new Date(pr.merged_at) > latestDateInChangelog &&
 | 
			
		||||
            !pr.labels.some(label =>
 | 
			
		||||
              ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase())
 | 
			
		||||
              )
 | 
			
		||||
            ).forEach(pr => {
 | 
			
		||||
 | 
			
		||||
              const prLabels = pr.labels.map(label => label.name.toLowerCase());
 | 
			
		||||
              const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
 | 
			
		||||
 | 
			
		||||
              let isCategorized = false;
 | 
			
		||||
 | 
			
		||||
              for (const { labels, notes } of categorizedPRs) {
 | 
			
		||||
                // If no labels are specified (e.g., "Unlabelled"), assign to this category
 | 
			
		||||
                if (labels.length === 0 && prLabels.length === 0) {
 | 
			
		||||
                  notes.push(prNote);
 | 
			
		||||
                  isCategorized = true;
 | 
			
		||||
                  break;
 | 
			
		||||
                }
 | 
			
		||||
              const updateScriptsCategory = categorizedPRs.find(category =>
 | 
			
		||||
                category.labels.some(label => prLabels.includes(label))
 | 
			
		||||
              );
 | 
			
		||||
 | 
			
		||||
              if (updateScriptsCategory) {
 | 
			
		||||
                
 | 
			
		||||
                const subCategory = updateScriptsCategory.subCategories.find(sub =>
 | 
			
		||||
                  sub.labels.some(label => prLabels.includes(label))
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                if (subCategory) {
 | 
			
		||||
                  subCategory.notes.push(prNote);
 | 
			
		||||
                } else {
 | 
			
		||||
                  updateScriptsCategory.notes.push(prNote);
 | 
			
		||||
 | 
			
		||||
                // If labels are specified, check if PR has ALL required labels
 | 
			
		||||
                if (labels.length > 0 && labels.every(label => prLabels.includes(label.toLowerCase()))) {
 | 
			
		||||
                  notes.push(prNote);
 | 
			
		||||
                  isCategorized = true;
 | 
			
		||||
                  break;
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
@@ -104,9 +115,12 @@ jobs:
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
            
 | 
			
		||||
            console.log(JSON.stringify(categorizedPRs, null, 2));
 | 
			
		||||
 | 
			
		||||
            return categorizedPRs;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      - name: Update CHANGELOG.md
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
        with:
 | 
			
		||||
@@ -119,13 +133,32 @@ jobs:
 | 
			
		||||
            const changelogPath = path.resolve('CHANGELOG.md');
 | 
			
		||||
            const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
 | 
			
		||||
 | 
			
		||||
            let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
 | 
			
		||||
            for (const { title, notes } of categorizedPRs) {
 | 
			
		||||
              if (notes.length > 0) {
 | 
			
		||||
                newReleaseNotes += `### ${title}\n\n${notes.join("\n")}\n\n`;
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
            console.log(JSON.stringify(categorizedPRs, null, 2));
 | 
			
		||||
 | 
			
		||||
            let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
 | 
			
		||||
            for (const { title, notes, subCategories } of categorizedPRs) {
 | 
			
		||||
              const hasSubcategories = subCategories && subCategories.length > 0;
 | 
			
		||||
              const hasMainNotes = notes.length > 0;
 | 
			
		||||
              const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);        
 | 
			
		||||
    
 | 
			
		||||
              if (hasMainNotes || hasSubNotes) {
 | 
			
		||||
                newReleaseNotes += `### ${title}\n\n`;
 | 
			
		||||
              }        
 | 
			
		||||
            
 | 
			
		||||
              if (hasMainNotes) {
 | 
			
		||||
                newReleaseNotes += `${notes.join("\n")}\n\n`;
 | 
			
		||||
              }        
 | 
			
		||||
             
 | 
			
		||||
              if (hasSubcategories) {
 | 
			
		||||
                for (const { title: subTitle, notes: subNotes } of subCategories) {
 | 
			
		||||
                  if (subNotes && subNotes.length > 0) {
 | 
			
		||||
                    newReleaseNotes += `  #### ${subTitle}\n\n`; 
 | 
			
		||||
                    newReleaseNotes += `  ${subNotes.join("\n    ")}\n\n`; 
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            }        
 | 
			
		||||
        
 | 
			
		||||
            const changelogContent = await fs.readFile(changelogPath, 'utf-8');
 | 
			
		||||
            const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user