diff options
| author | 2026-01-16 11:27:59 +0800 | |
|---|---|---|
| committer | 2026-01-16 11:27:59 +0800 | |
| commit | d02dd4df19e763a4dc94950e3a929ea454dfa500 (patch) | |
| tree | 9a498b9f97aab7067c83bffe81066415723b0d09 /.github/workflows | |
| parent | fa11a9152fdf519bb5f222d94e2ce937babb17fb (diff) | |
| parent | 11621cd4b4c9ed3bfdc12c2d3658d89dedcc8d8e (diff) | |
| download | DropOut-d02dd4df19e763a4dc94950e3a929ea454dfa500.tar.gz DropOut-d02dd4df19e763a4dc94950e3a929ea454dfa500.zip | |
Merge pull request #47 from BegoniaHe/chore/add-github-templates
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/issue-checkbox-checker.yml | 104 | ||||
| -rw-r--r-- | .github/workflows/issue-checker.yml | 84 | ||||
| -rw-r--r-- | .github/workflows/stale.yml | 92 |
3 files changed, 280 insertions, 0 deletions
diff --git a/.github/workflows/issue-checkbox-checker.yml b/.github/workflows/issue-checkbox-checker.yml new file mode 100644 index 0000000..ce7e011 --- /dev/null +++ b/.github/workflows/issue-checkbox-checker.yml @@ -0,0 +1,104 @@ +name: Issue Checkbox Checker + +on: + issues: + types: [opened, edited] + +permissions: + issues: write + +jobs: + check-checkboxes: + runs-on: ubuntu-latest + steps: + - name: Check for unchecked prerequisites + uses: actions/github-script@v7 + with: + script: | + const issue = context.payload.issue; + if (!issue) return; + + const body = issue.body || ''; + + // Check if "I have not read carefully" checkbox is checked + const notReadPatterns = [ + /- \[[xX]\] I have not read carefully/, + /- \[[xX]\] 我未仔细阅读/ + ]; + + const hasNotReadChecked = notReadPatterns.some(pattern => pattern.test(body)); + + if (hasNotReadChecked) { + const closeMessage = [ + '## Issue Automatically Closed / Issue 已自动关闭', + '', + '**English:**', + 'This issue has been automatically closed because you checked "I have not read carefully."', + '', + 'Please:', + '1. Read the [README](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/blob/main/README.md) and documentation carefully', + '2. Search for existing issues', + '3. Fill out the issue template completely', + '4. Submit a new issue when ready', + '', + '**中文:**', + '此 Issue 已被自动关闭,因为您勾选了"我未仔细阅读"。', + '', + '请:', + '1. 仔细阅读 [README](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/blob/main/README.md) 和文档', + '2. 搜索现有 Issue', + '3. 完整填写 Issue 模板', + '4. 准备好后提交新的 Issue', + '', + '---', + '*This is an automated action. If you believe this was done in error, please contact the maintainers.*' + ].join('\n'); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: closeMessage + }); + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed', + state_reason: 'not_planned' + }); + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: ['invalid', 'auto-closed'] + }); + + return; + } + + // Count total checkboxes and checked boxes + const totalBoxes = (body.match(/- \[[ xX]\]/g) || []).length; + const checkedBoxes = (body.match(/- \[[xX]\]/g) || []).length; + + // If no boxes are checked in prerequisites, add a reminder + if (totalBoxes > 0 && checkedBoxes === 0) { + const reminderMessage = [ + '## Reminder / 提醒', + '', + '**English:**', + 'Please check the prerequisite boxes in the issue template to confirm you have completed the required steps.', + '', + '**中文:**', + '请勾选 Issue 模板中的前置条件复选框,以确认您已完成必要步骤。' + ].join('\n'); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: reminderMessage + }); + } diff --git a/.github/workflows/issue-checker.yml b/.github/workflows/issue-checker.yml new file mode 100644 index 0000000..a598488 --- /dev/null +++ b/.github/workflows/issue-checker.yml @@ -0,0 +1,84 @@ +name: Issue Checker + +on: + issues: + types: [opened, edited] + pull_request_target: + types: [opened, edited] + +permissions: + issues: write + pull-requests: write + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Check and Label Issues + uses: actions/github-script@v7 + with: + script: | + const issue = context.payload.issue || context.payload.pull_request; + if (!issue) return; + + const body = issue.body || ''; + const title = issue.title || ''; + const isIssue = !!context.payload.issue; + const issueNumber = issue.number; + + // Skip if "I have not read carefully" is checked - handled by issue-checkbox-checker.yml + const hasNotReadChecked = + body.includes('- [x] I have not read carefully') || + body.includes('- [X] I have not read carefully') || + body.includes('- [x] 我未仔细阅读') || + body.includes('- [X] 我未仔细阅读'); + + if (hasNotReadChecked) { + // Let issue-checkbox-checker handle this + return; + } + + const labels = []; + + // Platform labels + if (body.match(/Windows|windows/i)) labels.push('platform: windows'); + if (body.match(/macOS|macos|Mac/i)) labels.push('platform: macos'); + if (body.match(/Linux|linux|Ubuntu|Debian|Arch|Fedora/i)) labels.push('platform: linux'); + + // Mod loader labels + if (body.match(/Fabric/i)) labels.push('mod-loader: fabric'); + if (body.match(/Forge/i)) labels.push('mod-loader: forge'); + + // Java related + if (body.match(/Java|java|JRE|JDK/i)) labels.push('java'); + + // Authentication issues + if (body.match(/login|authentication|Microsoft|Xbox|account/i)) labels.push('authentication'); + + // Download issues + if (body.match(/download|downloading|assets|libraries/i)) labels.push('download'); + + // Launch issues + if (body.match(/launch|start|won't start|crash|crashed/i)) labels.push('launch'); + + // UI issues + if (body.match(/UI|interface|display|rendering|visual/i)) labels.push('ui'); + + // Performance issues + if (body.match(/slow|performance|lag|freeze|hang/i)) labels.push('performance'); + + // Check for unclear titles + if (isIssue && (title.length < 10 || + title.match(/^(help|问题|stuck|卡住|error|错误|bug)$/i))) { + labels.push('needs-clarification'); + } + + // Apply labels + if (labels.length > 0) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: labels + }); + } diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..4005b2c --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,92 @@ +name: 'Close stale issues' + +on: + schedule: + - cron: '0 0 * * *' # Run daily at midnight UTC + workflow_dispatch: + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + # Issues + days-before-issue-stale: 90 + days-before-issue-close: 7 + stale-issue-label: 'stale' + exempt-issue-labels: 'pinned,enhancement,documentation' + stale-issue-message: | + ## This issue has been automatically marked as stale + ## 此 Issue 已被自动标记为过期 + + **English:** + This issue has had no activity for 90 days and will be closed in 7 days if no further activity occurs. + + If this issue is still relevant: + - Comment with an update + - Provide additional information + - Confirm you're still experiencing the problem + + **中文:** + 此 Issue 已 90 天无活动,如果继续无活动将在 7 天后关闭。 + + 如果此问题仍然相关: + - 发表评论更新状态 + - 提供额外信息 + - 确认您仍在遇到该问题 + + --- + *This is an automated message. To prevent closure, simply comment on this issue.* + close-issue-message: | + ## This issue has been automatically closed + ## 此 Issue 已被自动关闭 + + **English:** + This issue was automatically closed due to inactivity. If you're still experiencing this problem, please open a new issue with updated information. + + **中文:** + 此 Issue 因无活动而被自动关闭。如果您仍然遇到此问题,请开启一个新的 Issue 并提供最新信息。 + + # Pull Requests + days-before-pr-stale: 60 + days-before-pr-close: 14 + stale-pr-label: 'stale' + exempt-pr-labels: 'pinned,security' + stale-pr-message: | + ## This pull request has been automatically marked as stale + ## 此 PR 已被自动标记为过期 + + **English:** + This pull request has had no activity for 60 days and will be closed in 14 days if no further activity occurs. + + If you're still working on this: + - Push new commits + - Comment with a status update + - Request a review + + **中文:** + 此 PR 已 60 天无活动,如果继续无活动将在 14 天后关闭。 + + 如果您仍在处理此问题: + - 推送新的提交 + - 发表评论更新状态 + - 请求审查 + close-pr-message: | + ## This pull request has been automatically closed + ## 此 PR 已被自动关闭 + + **English:** + This pull request was automatically closed due to inactivity. Feel free to reopen if you resume work on this. + + **中文:** + 此 PR 因无活动而被自动关闭。如果您恢复工作,请随时重新开启。 + + # General settings + operations-per-run: 100 + remove-stale-when-updated: true + ascending: true |