From 71c4f84517ffcedd2042b0d96d89122743321fd7 Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:24:41 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Optimiere=20Workflow=20zum=20Kopieren=20von?= =?UTF-8?q?=20Labels,=20um=20verkn=C3=BCpfte=20Issues=20=C3=BCber=20die=20?= =?UTF-8?q?Timeline=20zu=20identifizieren=20und=20die=20Logik=20zur=20Fehl?= =?UTF-8?q?erbehandlung=20zu=20verbessern.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/copy-issue-labels.yml | 27 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml index f9624fb..aa2e6d1 100644 --- a/.github/workflows/copy-issue-labels.yml +++ b/.github/workflows/copy-issue-labels.yml @@ -1,4 +1,3 @@ -# .github/workflows/copy-issue-labels.yml name: Copy issue labels to PR on: @@ -19,15 +18,29 @@ jobs: with: script: | const prNumber = context.payload.pull_request.number; - const body = context.payload.pull_request.body || ''; - const match = body.match(/(?:Fixes|Closes|Resolves):?\s+#(\d+)/i); - if (!match) { - core.info('No issue reference found in PR body.'); + const timeline = await github.paginate( + github.rest.issues.listEventsForTimeline, + { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + per_page: 100 + } + ); + + const linkedIssue = timeline.find(e => + e.event === 'connected' && + e.source?.type === 'issue' && + e.source?.issue?.number + ); + + if (!linkedIssue) { + core.info('No linked issue found via timeline.'); return; } - const issueNumber = parseInt(match[1], 10); + const issueNumber = linkedIssue.source.issue.number; core.info(`Found linked issue #${issueNumber}`); const issue = await github.rest.issues.get({ @@ -38,7 +51,7 @@ jobs: const labels = issue.data.labels.map(label => label.name); if (labels.length === 0) { - core.info('No labels found on linked issue.'); + core.info('Linked issue has no labels.'); return; } From 1da72341e4fa12169a70101487e57d91e573aeca Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:27:18 +0200 Subject: [PATCH 2/7] =?UTF-8?q?Aktualisiere=20Workflow=20zum=20Kopieren=20?= =?UTF-8?q?von=20Labels:=20verbessere=20Lesbarkeit=20und=20f=C3=BCge=20zus?= =?UTF-8?q?=C3=A4tzliche=20PR-Typen=20hinzu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/copy-issue-labels.yml | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml index aa2e6d1..cfc236c 100644 --- a/.github/workflows/copy-issue-labels.yml +++ b/.github/workflows/copy-issue-labels.yml @@ -1,8 +1,13 @@ -name: Copy issue labels to PR +name: Copy labels from linked issue to PR on: pull_request: - types: [opened, reopened, synchronize] + types: + - opened + - reopened + - synchronize + - ready_for_review + - edited permissions: contents: read @@ -12,6 +17,7 @@ permissions: jobs: copy-issue-labels: runs-on: ubuntu-latest + steps: - name: Copy labels from linked issue uses: actions/github-script@v7 @@ -29,19 +35,19 @@ jobs: } ); - const linkedIssue = timeline.find(e => - e.event === 'connected' && - e.source?.type === 'issue' && - e.source?.issue?.number + const linkedIssue = timeline.find(event => + event.event === 'connected' && + event.source?.type === 'issue' && + event.source?.issue?.number ); if (!linkedIssue) { - core.info('No linked issue found via timeline.'); + core.info('❌ Kein verknüpfter Issue gefunden.'); return; } const issueNumber = linkedIssue.source.issue.number; - core.info(`Found linked issue #${issueNumber}`); + core.info(`✅ Verknüpfter Issue: #${issueNumber}`); const issue = await github.rest.issues.get({ owner: context.repo.owner, @@ -51,7 +57,7 @@ jobs: const labels = issue.data.labels.map(label => label.name); if (labels.length === 0) { - core.info('Linked issue has no labels.'); + core.info('ℹ️ Keine Labels auf dem verknüpften Issue.'); return; } @@ -62,4 +68,4 @@ jobs: labels }); - core.info(`Copied labels to PR: ${labels.join(', ')}`); + core.info(`🏷️ Labels übertragen: ${labels.join(', ')}`); From 4977de02b73951aed7a0f50a2f373b1ef27dc723 Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:30:29 +0200 Subject: [PATCH 3/7] =?UTF-8?q?Aktualisiere=20Workflow=20zum=20Kopieren=20?= =?UTF-8?q?von=20Labels:=20f=C3=BCge=20Debug-Informationen=20zur=20Timelin?= =?UTF-8?q?e=20hinzu=20und=20verbessere=20die=20Lesbarkeit=20der=20Konsole?= =?UTF-8?q?nausgaben.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/copy-issue-labels.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml index cfc236c..32d81f5 100644 --- a/.github/workflows/copy-issue-labels.yml +++ b/.github/workflows/copy-issue-labels.yml @@ -1,4 +1,4 @@ -name: Copy labels from linked issue to PR +name: Copy labels from linked issue to PR (Debug) on: pull_request: @@ -19,11 +19,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Copy labels from linked issue + - name: Copy timeline + copy labels uses: actions/github-script@v7 with: script: | const prNumber = context.payload.pull_request.number; + console.log(`🔍 PR #${prNumber}`); const timeline = await github.paginate( github.rest.issues.listEventsForTimeline, @@ -35,6 +36,18 @@ jobs: } ); + console.log(`📜 Timeline-Einträge (${timeline.length}):`); + timeline.forEach((event, i) => { + const base = `#${i + 1} [${event.event}]`; + if (event.source?.type === 'issue') { + const issue = event.source.issue; + const summary = issue?.number ? ` → Issue #${issue.number}` : ''; + console.log(`${base}${summary}`); + } else { + console.log(base); + } + }); + const linkedIssue = timeline.find(event => event.event === 'connected' && event.source?.type === 'issue' && @@ -42,7 +55,7 @@ jobs: ); if (!linkedIssue) { - core.info('❌ Kein verknüpfter Issue gefunden.'); + core.warning('❌ Kein verknüpfter Issue über Timeline gefunden.'); return; } From d691a4b2e8bb9112b5305aa4a975416f31fe1c9d Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:33:20 +0200 Subject: [PATCH 4/7] Entferne Debug-Informationen aus dem Workflow zum Kopieren von Labels und verbessere die Konsolenausgaben. --- .github/workflows/copy-issue-labels.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml index 32d81f5..8fbb1c7 100644 --- a/.github/workflows/copy-issue-labels.yml +++ b/.github/workflows/copy-issue-labels.yml @@ -1,4 +1,4 @@ -name: Copy labels from linked issue to PR (Debug) +name: Copy labels from linked issue to PR on: pull_request: @@ -38,14 +38,8 @@ jobs: console.log(`📜 Timeline-Einträge (${timeline.length}):`); timeline.forEach((event, i) => { - const base = `#${i + 1} [${event.event}]`; - if (event.source?.type === 'issue') { - const issue = event.source.issue; - const summary = issue?.number ? ` → Issue #${issue.number}` : ''; - console.log(`${base}${summary}`); - } else { - console.log(base); - } + const label = `#${i + 1} [${event.event}]`; + console.log(`${label} ${JSON.stringify(event, null, 2)}`); }); const linkedIssue = timeline.find(event => From a43324ff064ee5ad0bff406a503dfe6e68727f87 Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:43:04 +0200 Subject: [PATCH 5/7] =?UTF-8?q?F=C3=BCge=20Workflow=20hinzu,=20um=20vollst?= =?UTF-8?q?=C3=A4ndiges=20PR-JSON=20zu=20drucken=20und=20Debug-Information?= =?UTF-8?q?en=20bereitzustellen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/debug.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/debug.yaml diff --git a/.github/workflows/debug.yaml b/.github/workflows/debug.yaml new file mode 100644 index 0000000..049d388 --- /dev/null +++ b/.github/workflows/debug.yaml @@ -0,0 +1,29 @@ +name: "Debug: Print full PR JSON" + +on: + pull_request: + types: [opened, reopened, synchronize, ready_for_review, edited] + +permissions: + contents: read + pull-requests: read + +jobs: + print-pr-debug: + runs-on: ubuntu-latest + + steps: + - name: Get and print full PR object + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }); + + console.log(`🔍 PR #${prNumber} Vollständiges JSON:`); + console.log(JSON.stringify(pr, null, 2)); From 198c61897d092990eba43a2394987ce4cd301f1a Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:47:54 +0200 Subject: [PATCH 6/7] Aktualisiere Workflow zum Kopieren von Labels: verbessere die Verarbeitung von Issue-Referenzen und entferne den Debug-Workflow. --- .github/workflows/copy-issue-labels.yml | 79 +++++++++++-------------- .github/workflows/debug.yaml | 29 --------- 2 files changed, 33 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/debug.yaml diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml index 8fbb1c7..2d37861 100644 --- a/.github/workflows/copy-issue-labels.yml +++ b/.github/workflows/copy-issue-labels.yml @@ -1,13 +1,8 @@ -name: Copy labels from linked issue to PR +name: Copy labels from referenced issues to PR on: pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - - edited + types: [opened, reopened, synchronize, ready_for_review, edited] permissions: contents: read @@ -19,60 +14,52 @@ jobs: runs-on: ubuntu-latest steps: - - name: Copy timeline + copy labels + - name: Copy labels from issues mentioned in PR body uses: actions/github-script@v7 with: script: | - const prNumber = context.payload.pull_request.number; - console.log(`🔍 PR #${prNumber}`); + const pr = context.payload.pull_request; + const prNumber = pr.number; + const prBody = pr.body || ''; - const timeline = await github.paginate( - github.rest.issues.listEventsForTimeline, - { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - per_page: 100 - } - ); - - console.log(`📜 Timeline-Einträge (${timeline.length}):`); - timeline.forEach((event, i) => { - const label = `#${i + 1} [${event.event}]`; - console.log(`${label} ${JSON.stringify(event, null, 2)}`); - }); + // Finde alle Issue-Referenzen (#12, Fixes #13 etc.) + const issueMatches = [...prBody.matchAll(/(?:Fixes|Closes|Resolves)?\s*#(\d+)/gi)]; + const issueNumbers = [...new Set(issueMatches.map(m => parseInt(m[1], 10)))]; - const linkedIssue = timeline.find(event => - event.event === 'connected' && - event.source?.type === 'issue' && - event.source?.issue?.number - ); - - if (!linkedIssue) { - core.warning('❌ Kein verknüpfter Issue über Timeline gefunden.'); + if (issueNumbers.length === 0) { + core.info('📭 Keine referenzierten Issues im PR-Text gefunden.'); return; } - const issueNumber = linkedIssue.source.issue.number; - core.info(`✅ Verknüpfter Issue: #${issueNumber}`); + core.info(`🔗 Verlinkte Issues: ${issueNumbers.join(', ')}`); - const issue = await github.rest.issues.get({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber - }); + const allLabels = new Set(); + + for (const issueNumber of issueNumbers) { + core.info(`📥 Lese Labels von Issue #${issueNumber} ...`); + try { + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber + }); + + issue.data.labels.forEach(label => allLabels.add(label.name)); + } catch (error) { + core.warning(`⚠️ Issue #${issueNumber} konnte nicht gelesen werden: ${error.message}`); + } + } - const labels = issue.data.labels.map(label => label.name); - if (labels.length === 0) { - core.info('ℹ️ Keine Labels auf dem verknüpften Issue.'); + const labelList = [...allLabels]; + if (labelList.length === 0) { + core.info('📭 Keine Labels zum Übertragen gefunden.'); return; } + core.info(`🏷️ Übertrage Labels auf PR #${prNumber}: ${labelList.join(', ')}`); await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, - labels + labels: labelList }); - - core.info(`🏷️ Labels übertragen: ${labels.join(', ')}`); diff --git a/.github/workflows/debug.yaml b/.github/workflows/debug.yaml deleted file mode 100644 index 049d388..0000000 --- a/.github/workflows/debug.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: "Debug: Print full PR JSON" - -on: - pull_request: - types: [opened, reopened, synchronize, ready_for_review, edited] - -permissions: - contents: read - pull-requests: read - -jobs: - print-pr-debug: - runs-on: ubuntu-latest - - steps: - - name: Get and print full PR object - uses: actions/github-script@v7 - with: - script: | - const prNumber = context.payload.pull_request.number; - - const { data: pr } = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: prNumber - }); - - console.log(`🔍 PR #${prNumber} Vollständiges JSON:`); - console.log(JSON.stringify(pr, null, 2)); From c15551560b0680130f4adfec7e8ec50c77f01702 Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:48:53 +0200 Subject: [PATCH 7/7] Entferne Workflow zum Kopieren von Labels aus Issues --- .github/workflows/copy-issue-labels.yml | 65 ------------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/copy-issue-labels.yml diff --git a/.github/workflows/copy-issue-labels.yml b/.github/workflows/copy-issue-labels.yml deleted file mode 100644 index 2d37861..0000000 --- a/.github/workflows/copy-issue-labels.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Copy labels from referenced issues to PR - -on: - pull_request: - types: [opened, reopened, synchronize, ready_for_review, edited] - -permissions: - contents: read - issues: read - pull-requests: write - -jobs: - copy-issue-labels: - runs-on: ubuntu-latest - - steps: - - name: Copy labels from issues mentioned in PR body - uses: actions/github-script@v7 - with: - script: | - const pr = context.payload.pull_request; - const prNumber = pr.number; - const prBody = pr.body || ''; - - // Finde alle Issue-Referenzen (#12, Fixes #13 etc.) - const issueMatches = [...prBody.matchAll(/(?:Fixes|Closes|Resolves)?\s*#(\d+)/gi)]; - const issueNumbers = [...new Set(issueMatches.map(m => parseInt(m[1], 10)))]; - - if (issueNumbers.length === 0) { - core.info('📭 Keine referenzierten Issues im PR-Text gefunden.'); - return; - } - - core.info(`🔗 Verlinkte Issues: ${issueNumbers.join(', ')}`); - - const allLabels = new Set(); - - for (const issueNumber of issueNumbers) { - core.info(`📥 Lese Labels von Issue #${issueNumber} ...`); - try { - const issue = await github.rest.issues.get({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber - }); - - issue.data.labels.forEach(label => allLabels.add(label.name)); - } catch (error) { - core.warning(`⚠️ Issue #${issueNumber} konnte nicht gelesen werden: ${error.message}`); - } - } - - const labelList = [...allLabels]; - if (labelList.length === 0) { - core.info('📭 Keine Labels zum Übertragen gefunden.'); - return; - } - - core.info(`🏷️ Übertrage Labels auf PR #${prNumber}: ${labelList.join(', ')}`); - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - labels: labelList - });