mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	[gh] better handling of labels (#2517)
* Update autolabeler.yml * Update changelog-pr-config.json
This commit is contained in:
		
							
								
								
									
										36
									
								
								.github/changelog-pr-config.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								.github/changelog-pr-config.json
									
									
									
									
										vendored
									
									
								
							@@ -1,34 +1,38 @@
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
      "title": "💥 Breaking Changes",
 | 
			
		||||
      "labels": ["breaking change"]
 | 
			
		||||
    "title": "💥 Breaking Changes",
 | 
			
		||||
    "labels": ["breaking change"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "✨ New Scripts",
 | 
			
		||||
      "labels": ["new script"]
 | 
			
		||||
    "title": "✨ New Scripts",
 | 
			
		||||
    "labels": ["new script"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "🚀 Updated Scripts",
 | 
			
		||||
      "labels": ["update script"]
 | 
			
		||||
    "title": "🚀 Updated Scripts",
 | 
			
		||||
    "labels": ["update script"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "🌐 Website",
 | 
			
		||||
      "labels": ["website"]
 | 
			
		||||
    "title": "🆕 Features",
 | 
			
		||||
    "labels": ["new feature"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "🐞 Bug Fixes",
 | 
			
		||||
      "labels": ["bug fix"]
 | 
			
		||||
    "title": "🌐 Website",
 | 
			
		||||
    "labels": ["website"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "🧰 Maintenance",
 | 
			
		||||
      "labels": ["maintenance"]
 | 
			
		||||
    "title": "🐞 Bug Fixes",
 | 
			
		||||
    "labels": ["bug fix"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "📡 API",
 | 
			
		||||
      "labels": ["api"]
 | 
			
		||||
    "title": "🧰 Maintenance",
 | 
			
		||||
    "labels": ["maintenance"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
      "title": "❔ Unlabelled",
 | 
			
		||||
      "labels": []
 | 
			
		||||
    "title": "📡 API",
 | 
			
		||||
    "labels": ["api"]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "title": "❔ Unlabelled",
 | 
			
		||||
    "labels": []
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										54
									
								
								.github/workflows/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								.github/workflows/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							@@ -19,7 +19,7 @@ jobs:
 | 
			
		||||
      - name: Install minimatch
 | 
			
		||||
        run: npm install minimatch
 | 
			
		||||
 | 
			
		||||
      - name: Label PR based on config rules
 | 
			
		||||
      - name: Label PR based on file changes
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
        with:
 | 
			
		||||
          script: |
 | 
			
		||||
@@ -39,6 +39,8 @@ jobs:
 | 
			
		||||
            });
 | 
			
		||||
            const prFiles = prListFilesResponse.data;
 | 
			
		||||
 | 
			
		||||
            let labelsToAdd = new Set();
 | 
			
		||||
 | 
			
		||||
            for (const [label, rules] of Object.entries(autolabelerConfig)) {
 | 
			
		||||
              const shouldAddLabel = prFiles.some((prFile) => {
 | 
			
		||||
                return rules.some((rule) => {
 | 
			
		||||
@@ -51,12 +53,48 @@ jobs:
 | 
			
		||||
              });
 | 
			
		||||
 | 
			
		||||
              if (shouldAddLabel) {
 | 
			
		||||
                console.log(`Adding label ${label} to PR ${prNumber}`);
 | 
			
		||||
                await github.rest.issues.addLabels({
 | 
			
		||||
                  owner: context.repo.owner,
 | 
			
		||||
                  repo: context.repo.repo,
 | 
			
		||||
                  issue_number: prNumber,
 | 
			
		||||
                  labels: [label],
 | 
			
		||||
                });
 | 
			
		||||
                labelsToAdd.add(label);
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (labelsToAdd.size > 0) {
 | 
			
		||||
              console.log(`Adding labels ${Array.from(labelsToAdd).join(", ")} to PR ${prNumber}`);
 | 
			
		||||
              await github.rest.issues.addLabels({
 | 
			
		||||
                owner: context.repo.owner,
 | 
			
		||||
                repo: context.repo.repo,
 | 
			
		||||
                issue_number: prNumber,
 | 
			
		||||
                labels: Array.from(labelsToAdd),
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
      - name: Label PR based on PR template selections
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
        with:
 | 
			
		||||
          script: |
 | 
			
		||||
            const prBody = context.payload.pull_request.body.toLowerCase();
 | 
			
		||||
            const prNumber = context.payload.pull_request.number;
 | 
			
		||||
            const labelMappings = {
 | 
			
		||||
              "🐞 bug fix": "bug fix",
 | 
			
		||||
              "✨ new feature": "new feature",
 | 
			
		||||
              "💥 breaking change": "breaking change",
 | 
			
		||||
              "🆕 new script": "new script"
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            let labelsToAdd = new Set();
 | 
			
		||||
 | 
			
		||||
            for (const [checkbox, label] of Object.entries(labelMappings)) {
 | 
			
		||||
              const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
 | 
			
		||||
              if (regex.test(prBody)) {
 | 
			
		||||
                labelsToAdd.add(label);
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (labelsToAdd.size > 0) {
 | 
			
		||||
              console.log(`Adding labels ${Array.from(labelsToAdd).join(", ")} to PR ${prNumber}`);
 | 
			
		||||
              await github.rest.issues.addLabels({
 | 
			
		||||
                owner: context.repo.owner,
 | 
			
		||||
                repo: context.repo.repo,
 | 
			
		||||
                issue_number: prNumber,
 | 
			
		||||
                labels: Array.from(labelsToAdd),
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user