|
| 1 | +name: Issue or PR Auto Reply |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened] |
| 6 | + pull_request: |
| 7 | + types: [opened] |
| 8 | + |
| 9 | +permissions: |
| 10 | + issues: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + auto-reply: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: github.event_name == 'issues' |
| 17 | + steps: |
| 18 | + - name: Check issue for unchecked tasks and reply |
| 19 | + uses: actions/github-script@v7 |
| 20 | + with: |
| 21 | + script: | |
| 22 | + const issueBody = context.payload.issue.body || ""; |
| 23 | + const unchecked = /- \[ \] /.test(issueBody); |
| 24 | + let comment = "感谢您联系OpenList。我们会尽快回复您。\n"; |
| 25 | + comment += "Thanks for contacting OpenList. We will reply to you as soon as possible.\n\n"; |
| 26 | + if (unchecked) { |
| 27 | + comment += "由于您提出的 Issue 中包含部分未确认的项目,为了更好地管理项目,在人工审核后可能会直接关闭此问题。\n"; |
| 28 | + comment += "如果您能确认并补充相关未确认项目的信息,欢迎随时重新提交。我们会及时关注并处理。感谢您的理解与支持!\n"; |
| 29 | + comment += "Since your issue contains some unchecked tasks, it may be closed after manual review.\n"; |
| 30 | + comment += "If you can confirm and provide information for the unchecked tasks, feel free to resubmit.\n"; |
| 31 | + comment += "We will pay attention and handle it in a timely manner.\n\n"; |
| 32 | + comment += "感谢您的理解与支持!\n"; |
| 33 | + comment += "Thank you for your understanding and support!\n"; |
| 34 | + } |
| 35 | + await github.rest.issues.createComment({ |
| 36 | + ...context.repo, |
| 37 | + issue_number: context.issue.number, |
| 38 | + body: comment |
| 39 | + }); |
| 40 | +
|
| 41 | + pr-title-check: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + if: github.event_name == 'pull_request' |
| 44 | + steps: |
| 45 | + - name: Check PR title for required prefix and comment |
| 46 | + uses: actions/github-script@v7 |
| 47 | + with: |
| 48 | + script: | |
| 49 | + const title = context.payload.pull_request.title || ""; |
| 50 | + const ok = /^(feat|docs|fix|style|refactor|chore)\(.+\): /i.test(title); |
| 51 | + if (!ok) { |
| 52 | + let comment = "⚠️ PR 标题需以 `feat(): `, `docs(): `, `fix(): `, `style(): `, `refactor(): ` 其中之一开头,例如:`feat(component): 新增功能`。"; |
| 53 | + comment += "⚠️ The PR title must start with `feat(): `, `docs(): `, `fix(): `, `style(): `, or `refactor(): `. For example: `feat(component): add new feature`.\n\n"; |
| 54 | + await github.rest.issues.createComment({ |
| 55 | + ...context.repo, |
| 56 | + issue_number: context.issue.number, |
| 57 | + body: comment |
| 58 | + }); |
| 59 | + } |
0 commit comments