name: Automatically reply to React19 related issues

on:
  issues:
    types: [opened, edited, labeled]

jobs:
  auto-reply:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            const issue = context.payload.issue;
            
            const keywords = ['react19', 'react 19'];
            const hasKeyword = keywords.some(keyword => 
              issue.title.toLowerCase().includes(keyword.toLowerCase())
            );

            const isLabeledReact19 = issue.labels.some(label => label.name === 'react19');
            
            const mentionedIssueRegex = /#(\d+)/g;
            const mentionedIssues = [...issue.body.matchAll(mentionedIssueRegex)].map(match => match[1]);
            const importantIssues = ['2743']; // 要监听的issue编号
            const hasMentionedImportantIssue = mentionedIssues.some(num => importantIssues.includes(num));
            
            if (hasKeyword || hasMentionedImportantIssue || isLabeledReact19) {
              github.rest.issues.createComment({
                issue_number: issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: `感谢您反馈 Semi 在 React 19 下使用的异常问题！我们团队预计将在 2025 年 Q3 进行 React 19 的全面适配与优化工作，目前处于收集问题阶段，您的反馈将在 React 19 适配完成后得到处理，详细信息可参考 [issue](https://github.com/DouyinFE/semi-design/issues/2743)。
                 Thank you for your feedback on the abnormal issues when using Semi under React 19! Our team plans to fully adapt and optimize React 19 in Q3 2025. We are currently in the stage of collecting issues. Your feedback will be processed after the adaptation of React 19 is completed. For more information, please refer to [issue](https://github.com/DouyinFE/semi-design/issues/2743).`
              });
            }