diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index c4ccd74eb3..66c9119914 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -49,6 +49,10 @@ body: label: Log File description: >- Attach the most recent log file from your client (`logs/latest.log`). This file should always be present. + + **Important:** Upload the file to this issue as an attachment by first selecting the text box below and then dragging your file onto it. + GitHub will upload the file as an attachment and generate a link to it. This issue will be automatically closed if you omit a log + file or copy-paste its content here. placeholder: >- Upload the log file here... validations: @@ -58,7 +62,7 @@ body: attributes: label: Crash Report description: >- - Attach the most recent crash report from the `crash-reports` folder. This is different from the log file above, and it contains + Attach the most recent crash report from the `crash-reports` folder in the same manner as before. This is different from the log file above, and it contains important information about your hardware and software configuration. **Important:** If your game is not crashing as a result of your problem, then you need to obtain a crash report manually. This can be done diff --git a/.github/workflows/verify-issue.yml b/.github/workflows/verify-issue.yml new file mode 100644 index 0000000000..462d91032f --- /dev/null +++ b/.github/workflows/verify-issue.yml @@ -0,0 +1,74 @@ +name: Verify Issue +on: + issues: + types: + - opened + - edited + - reopened +jobs: + moderate: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + id: verify-issue + with: + result-encoding: string + script: | + const issue_payload = context.payload.issue; + const issue_content = issue_payload.body; + if (issue_payload.pull_request != null || !issue_content.startsWith("### Bug Description")) { + return; + } + + const author_name = issue_payload.user ? issue_payload.user.login : context.payload.sender.login; + const LOG_FILE_REGEX = /### Log File[^]+?\[.+\.(txt|log)\]\(https:\/\/github\.com\/\w+\/sodium-fabric\/files\/\d+\/.+\.(txt|log)\)/; + const CRASH_REPORT_REGEX = /### Crash Report[^]+?\[.+\.(txt|log)\]\(https:\/\/github\.com\/\w+\/sodium-fabric\/files\/\d+\/.+\.(txt|log)\)/; + + if (issue_payload.state == "open") { + let match = LOG_FILE_REGEX.exec(issue_content); + if (!match || match[0].includes("### Crash Report")) { + await github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: "closed", + state_reason: "not_planned", + labels: ["E-invalid"], + }) + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `@${author_name}, this issue was automatically closed because it did not follow the issue template. You either did not upload a log file or didn't upload it in the required format. Attach a log file and a crashlog as described in the issue template by dragging and dropping the file and letting GitHub create an attachment. Do not copy-paste the content of the log file into the area. Please edit your issue to add the required data and the issue will be automatically be reopened.`, + }); + } else if (!CRASH_REPORT_REGEX.test(issue_content)) { + await github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: "closed", + state_reason: "not_planned", + labels: ["E-invalid"], + }) + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `@${author_name}, this issue was automatically closed because it did not follow the issue template. You either did not upload a crash log or didn't upload it in the required format. Attach a log file and a crash log as described in the issue template by dragging and dropping the file and letting GitHub create an attachment. Do not copy-paste the content of the log file into the area. Please edit your issue to add the required data and the issue will be automatically be reopened.`, + }); + } + } else if (issue_payload.labels.some(label => label.name == "E-invalid") && LOG_FILE_REGEX.test(issue_content) && CRASH_REPORT_REGEX.test(issue_content)) { + await github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: "open", + labels: ["S-needs-triage"], + }) + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Reopened because the issue now follows the issue template.", + }); + }