mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Update autolabeler.yml
This commit is contained in:
		
							
								
								
									
										33
									
								
								.github/workflows/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								.github/workflows/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							@@ -19,7 +19,7 @@ jobs:
 | 
			
		||||
      - name: Install minimatch
 | 
			
		||||
        run: npm install minimatch
 | 
			
		||||
 | 
			
		||||
      - name: Label PR based on file changes
 | 
			
		||||
      - name: Label PR based on file changes and PR template
 | 
			
		||||
        uses: actions/github-script@v7
 | 
			
		||||
        with:
 | 
			
		||||
          script: |
 | 
			
		||||
@@ -32,6 +32,10 @@ jobs:
 | 
			
		||||
            const autolabelerConfig = JSON.parse(fileContent);
 | 
			
		||||
 | 
			
		||||
            const prNumber = context.payload.pull_request.number;
 | 
			
		||||
            const prBody = context.payload.pull_request.body.toLowerCase();
 | 
			
		||||
            
 | 
			
		||||
            let labelsToAdd = new Set();
 | 
			
		||||
 | 
			
		||||
            const prListFilesResponse = await github.rest.pulls.listFiles({
 | 
			
		||||
              owner: context.repo.owner,
 | 
			
		||||
              repo: context.repo.repo,
 | 
			
		||||
@@ -39,8 +43,6 @@ 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) => {
 | 
			
		||||
@@ -57,34 +59,17 @@ jobs:
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            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 = {
 | 
			
		||||
            const templateLabelMappings = {
 | 
			
		||||
              "🐞 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)) {
 | 
			
		||||
            for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
 | 
			
		||||
              const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
 | 
			
		||||
              if (regex.test(prBody)) {
 | 
			
		||||
              const match = prBody.match(regex);
 | 
			
		||||
              if (match && match[1].trim() !== "") { // Checkbox ist gesetzt
 | 
			
		||||
                labelsToAdd.add(label);
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user