mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Update changelog-pr.yml
This commit is contained in:
		
							
								
								
									
										66
									
								
								.github/workflows/changelog-pr.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								.github/workflows/changelog-pr.yml
									
									
									
									
										vendored
									
									
								
							@@ -44,7 +44,7 @@ jobs:
 | 
			
		||||
            echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
 | 
			
		||||
          fi
 | 
			
		||||
 | 
			
		||||
      - name: Get categorized pull requests
 | 
			
		||||
      - name: Get categorized pull requests (including PR template selections)
 | 
			
		||||
        id: get-categorized-prs
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
        with:
 | 
			
		||||
@@ -54,7 +54,23 @@ jobs:
 | 
			
		||||
 | 
			
		||||
            const configPath = path.resolve(process.env.CONFIG_PATH);
 | 
			
		||||
            const fileContent = await fs.readFile(configPath, 'utf-8');
 | 
			
		||||
            const changelogConfig = JSON.parse(fileContent);
 | 
			
		||||
            let changelogConfig = JSON.parse(fileContent);
 | 
			
		||||
 | 
			
		||||
            // Reihenfolge der Kategorien beibehalten
 | 
			
		||||
            const order = [
 | 
			
		||||
              "💥 Breaking Changes",
 | 
			
		||||
              "🆕 New Scripts",
 | 
			
		||||
              "🚀 Updated Scripts",
 | 
			
		||||
              "🐞 Bug Fixes (Updated Scripts)",
 | 
			
		||||
              "✨ Feature Updates (Updated Scripts)",
 | 
			
		||||
              "✨ New Features",
 | 
			
		||||
              "🌐 Website",
 | 
			
		||||
              "📡 API",
 | 
			
		||||
              "🧰 Maintenance",
 | 
			
		||||
              "❔ Unlabelled"
 | 
			
		||||
            ];
 | 
			
		||||
            changelogConfig = changelogConfig.sort((a, b) => order.indexOf(a.title) - order.indexOf(b.title));
 | 
			
		||||
 | 
			
		||||
            const categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
 | 
			
		||||
 | 
			
		||||
            const latestDateInChangelog = new Date(process.env.LATEST_DATE);
 | 
			
		||||
@@ -76,17 +92,55 @@ jobs:
 | 
			
		||||
              !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 prBody = pr.body.toLowerCase();
 | 
			
		||||
              const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
 | 
			
		||||
 | 
			
		||||
              for (const { labels, notes } of categorizedPRs) {
 | 
			
		||||
                if (labels.length === 0 || labels.some(label => prLabels.includes(label))) {
 | 
			
		||||
              // Mapping für PR-Checkboxen → Labels
 | 
			
		||||
              const templateLabelMappings = {
 | 
			
		||||
                "🐞 bug fix": "bugfix",
 | 
			
		||||
                "✨ new feature": "feature",
 | 
			
		||||
                "💥 breaking change": "breaking change",
 | 
			
		||||
                "🆕 new script": "new script"
 | 
			
		||||
              };
 | 
			
		||||
 | 
			
		||||
              let addedByTemplate = false;
 | 
			
		||||
              for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
 | 
			
		||||
                const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
 | 
			
		||||
                const match = prBody.match(regex);
 | 
			
		||||
                if (match && match[1].trim() !== "") { // Checkbox ist gesetzt
 | 
			
		||||
                  prLabels.push(label);
 | 
			
		||||
                  addedByTemplate = true;
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
              // Unterteilung von "Updated Scripts"
 | 
			
		||||
              let categorized = false;
 | 
			
		||||
              for (const { labels, notes, title } of categorizedPRs) {
 | 
			
		||||
                if (labels.includes("update script") && labels.includes("bugfix")) {
 | 
			
		||||
                  if (title === "🐞 Bug Fixes (Updated Scripts)") {
 | 
			
		||||
                    notes.push(prNote);
 | 
			
		||||
                    categorized = true;
 | 
			
		||||
                    break;
 | 
			
		||||
                  }
 | 
			
		||||
                } else if (labels.includes("update script") && labels.includes("feature")) {
 | 
			
		||||
                  if (title === "✨ Feature Updates (Updated Scripts)") {
 | 
			
		||||
                    notes.push(prNote);
 | 
			
		||||
                    categorized = true;
 | 
			
		||||
                    break;
 | 
			
		||||
                  }
 | 
			
		||||
                } else if (labels.length === 0 || labels.some(label => prLabels.includes(label))) {
 | 
			
		||||
                  notes.push(prNote);
 | 
			
		||||
                  categorized = true;
 | 
			
		||||
                  break;
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
              if (addedByTemplate) {
 | 
			
		||||
                console.log(`PR #${pr.number} wurde durch PR-Template-Kategorie hinzugefügt`);
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            return categorizedPRs;
 | 
			
		||||
            core.setOutput("result", JSON.stringify(categorizedPRs));
 | 
			
		||||
 | 
			
		||||
      - name: Update CHANGELOG.md
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
@@ -98,7 +152,7 @@ jobs:
 | 
			
		||||
            const today = process.env.TODAY;
 | 
			
		||||
            const latestDateInChangelog = process.env.LATEST_DATE;
 | 
			
		||||
            const changelogPath = path.resolve('CHANGELOG.md');
 | 
			
		||||
            const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
 | 
			
		||||
            const categorizedPRs = JSON.parse(process.env.RESULT);
 | 
			
		||||
 | 
			
		||||
            let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
 | 
			
		||||
            for (const { title, notes } of categorizedPRs) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user