|
| 1 | +name: Slicing Error Check |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened, edited] |
| 6 | + |
| 7 | +permissions: |
| 8 | + issues: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + processSlicingError: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Check for project file and set output |
| 15 | + id: check_issue_details |
| 16 | + uses: actions/github-script@v7 |
| 17 | + with: |
| 18 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + script: | |
| 20 | + const issue = context.payload.issue; |
| 21 | + const issueNumber = issue.number; |
| 22 | +
|
| 23 | + console.log(`Processing issue #${issueNumber}: "${issue.title}"`); |
| 24 | +
|
| 25 | + const hasSlicingErrorLabel = issue.labels.some(label => label.name === 'Slicing Error :collision:'); |
| 26 | + const titleContainsSliceFailed = issue.title.toLowerCase().includes('slice failed'); |
| 27 | + const bodyText = issue.body || ""; |
| 28 | + const bodyContainsSliceFailed = bodyText.toLowerCase().includes('slice failed'); |
| 29 | + let setNeedsInfoOutput = false; |
| 30 | +
|
| 31 | + if (hasSlicingErrorLabel || titleContainsSliceFailed || bodyContainsSliceFailed) { |
| 32 | + console.log(`Issue #${issueNumber} matches slicing error criteria.`); |
| 33 | +
|
| 34 | + const zipRegex = /(\[[^\]]*?\]\(.*?\.zip\)|https?:\/\/[^\s]*?\.zip)/i; |
| 35 | + let hasZipAttachment = zipRegex.test(bodyText); |
| 36 | +
|
| 37 | + if (hasZipAttachment) { |
| 38 | + console.log(`Issue #${issueNumber} appears to have a .zip file linked in the body.`); |
| 39 | + } else { |
| 40 | + console.log(`Issue #${issueNumber} does not appear to have a .zip file linked in the body. Flagging for further action.`); |
| 41 | + setNeedsInfoOutput = true; |
| 42 | + } |
| 43 | + } else { |
| 44 | + console.log(`Issue #${issueNumber} does not match slicing error criteria. No action needed.`); |
| 45 | + } |
| 46 | + core.setOutput('needs_info', setNeedsInfoOutput.toString()); |
| 47 | +
|
| 48 | + - name: Add comment if project file is missing |
| 49 | + if: steps.check_issue_details.outputs.needs_info == 'true' |
| 50 | + uses: peter-evans/create-or-update-comment@v4 |
| 51 | + with: |
| 52 | + issue-number: ${{ github.event.issue.number }} |
| 53 | + body: | |
| 54 | + This issue is related to a slicing error, but it seems a project file (`.zip`) is missing. |
| 55 | + Please attach a `.zip` file containing your project (including models and profiles) so we can reproduce the issue. |
| 56 | + This will help us investigate and resolve the problem more effectively. |
| 57 | + Have Cura open with your project that fails to slice, go to `Help` > `Export Package For Technical Support`, and save the package. |
| 58 | + Then create a .zip file with the package, attach the `.zip` file to this issue. |
| 59 | + If you have already attached a `.zip` file, please ensure it is correctly linked in the issue body. |
| 60 | +
|
| 61 | + - name: Add Status Needs Info Label |
| 62 | + if: steps.check_issue_details.outputs.needs_info == 'true' |
| 63 | + uses: actions-ecosystem/action-add-labels@v1 |
| 64 | + with: |
| 65 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + labels: | |
| 67 | + Status: Needs Info |
0 commit comments