GGMax Bug - DevTest - Inventory Bug #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Forward crash issue to GameGuruMAX | |
| on: | |
| issues: | |
| types: [labeled] | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| forward: | |
| if: github.event.label.name == 'forward-to-max' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Forward issue to GameGuruMAX (include latest crash attachments comment) | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.MAX_ISSUE_BOT_TOKEN }} | |
| script: | | |
| const sourceOwner = context.repo.owner; | |
| const sourceRepo = context.repo.repo; | |
| const sourceNum = context.payload.issue.number; | |
| const issue = context.payload.issue; | |
| const targetOwner = "Dark-Basic-Software-Limited"; | |
| const targetRepo = "GameGuruMAX"; | |
| // Fetch all comments (paginate-safe) | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner: sourceOwner, | |
| repo: sourceRepo, | |
| issue_number: sourceNum, | |
| per_page: 100 | |
| }); | |
| // Find the latest comment that likely contains attachments/links | |
| const hasDmp = (s) => /https?:\/\/\S+\.dmp\b/i.test(s || ""); | |
| const hasLog = (s) => /https?:\/\/\S+Guru-Crash\.log\b/i.test(s || "") || /https?:\/\/\S+\.log\b/i.test(s || ""); | |
| // Prefer a comment that has BOTH .dmp and .log; else .dmp; else latest comment; else none. | |
| let chosen = null; | |
| for (let i = comments.length - 1; i >= 0; i--) { | |
| const b = comments[i].body || ""; | |
| if (hasDmp(b) && hasLog(b)) { chosen = comments[i]; break; } | |
| } | |
| if (!chosen) { | |
| for (let i = comments.length - 1; i >= 0; i--) { | |
| const b = comments[i].body || ""; | |
| if (hasDmp(b)) { chosen = comments[i]; break; } | |
| } | |
| } | |
| if (!chosen && comments.length) chosen = comments[comments.length - 1]; | |
| const chosenBlock = chosen | |
| ? [ | |
| "", | |
| "---", | |
| "", | |
| "🧾 **Latest crash report comment (from " + (chosen.user?.login || "unknown") + ")**", | |
| chosen.html_url, | |
| "", | |
| chosen.body || "" | |
| ].join("\n") | |
| : ""; | |
| const bodyLines = [ | |
| "**Source issue:** [" + sourceOwner + "/" + sourceRepo + "#" + sourceNum + "](" + issue.html_url + ")", | |
| "", | |
| "---", | |
| "", | |
| "**Original issue body:**", | |
| "", | |
| issue.body || "", | |
| chosenBlock | |
| ]; | |
| const created = await github.rest.issues.create({ | |
| owner: targetOwner, | |
| repo: targetRepo, | |
| title: issue.title, | |
| body: bodyLines.join("\n"), | |
| labels: ["crash-triage"] | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: sourceOwner, | |
| repo: sourceRepo, | |
| issue_number: sourceNum, | |
| body: "✅ Forwarded to: " + created.data.html_url + "\n\nIncluded the latest crash report comment with attachments/links." | |
| }); |