diff --git a/.github/workflows/autolabeler.yml b/.github/workflows/autolabeler.yml index 175572716..660135f5c 100644 --- a/.github/workflows/autolabeler.yml +++ b/.github/workflows/autolabeler.yml @@ -16,60 +16,47 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Install minimatch + run: npm install minimatch + - name: Label PR based on config rules uses: actions/github-script@v7 with: script: | const fs = require('fs').promises; const path = require('path'); - - // `require.resolve()` sorgt dafür, dass `minimatch` aus der GitHub-Umgebung geladen wird. - const minimatch = require(require.resolve("minimatch")); + const { minimatch } = require('minimatch'); const configPath = path.resolve(process.env.CONFIG_PATH); - let config; - try { - const fileContent = await fs.readFile(configPath, 'utf-8'); - config = JSON.parse(fileContent); - } catch (error) { - console.error(`❌ Fehler beim Laden der Konfigurationsdatei: ${error.message}`); - return; - } - + const fileContent = await fs.readFile(configPath, 'utf-8'); + const autolabelerConfig = JSON.parse(fileContent); + const prNumber = context.payload.pull_request.number; - const prFiles = (await github.rest.pulls.listFiles({ + const prListFilesResponse = await github.rest.pulls.listFiles({ owner: context.repo.owner, repo: context.repo.repo, pull_number: prNumber, - })).data; + }); + 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) => { + const isFileStatusMatch = rule.fileStatus ? rule.fileStatus === prFile.status : true; + const isIncludeGlobMatch = rule.includeGlobs.some((glob) => minimatch(prFile.filename, glob)); + const isExcludeGlobMatch = rule.excludeGlobs.some((glob) => minimatch(prFile.filename, glob)); + + return isFileStatusMatch && isIncludeGlobMatch && !isExcludeGlobMatch; + }); + }); - for (const [label, rules] of Object.entries(config)) { - if (prFiles.some(prFile => - rules.some(rule => - (!rule.fileStatus || rule.fileStatus === prFile.status) && - rule.includeGlobs.some(glob => minimatch(prFile.filename, glob)) && - !rule.excludeGlobs.some(glob => minimatch(prFile.filename, glob)) - ) - )) { - labelsToAdd.add(label); + 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], + }); } } - - const existingLabels = new Set((await github.rest.issues.listLabelsOnIssue({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - })).data.map(l => l.name)); - - labelsToAdd = [...labelsToAdd].filter(label => !existingLabels.has(label)); - - if (labelsToAdd.length > 0) { - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - labels: labelsToAdd, - }); - } diff --git a/json/zitadel.json b/json/zitadel.json index b2cec903b..8a147db3b 100644 --- a/json/zitadel.json +++ b/json/zitadel.json @@ -4,14 +4,14 @@ "categories": [ 6 ], - "date_created": "2025-02-07", + "date_created": "2025-02-10", "type": "ct", "updateable": true, "privileged": false, "interface_port": 8080, "documentation": "https://zitadel.com/docs/guides/overview", "website": "https://zitadel.com", - "logo": "https://zitadel.com/zitadel-logo-dark.svg", + "logo": "https://raw.githubusercontent.com/zitadel/zitadel/refs/heads/main/console/src/assets/icons/android-chrome-512x512.png", "description": "Zitadel is an open-source identity and access management (IAM) solution designed to provide secure authentication, authorization, and user management for modern applications and services. Built with a focus on flexibility, scalability, and security, Zitadel offers a comprehensive set of features for developers and organizations looking to implement robust identity management.", "install_methods": [ { @@ -40,4 +40,4 @@ "type": "info" } ] -} \ No newline at end of file +}