AI 科技日报 #83
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: AI 科技日报 | |
| on: | |
| schedule: | |
| # 每天北京时间 13:17(UTC 05:17) | |
| - cron: '17 5 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| issues: write | |
| jobs: | |
| daily-digest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Collect AI news and create issue | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const now = new Date(); | |
| const oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); | |
| const sinceDate = oneWeekAgo.toISOString().split('T')[0]; | |
| const todayStr = now.toISOString().split('T')[0]; | |
| // --- 1. GitHub 热门 AI 仓库(本周新创建 & 高星标) --- | |
| let trendingRepos = []; | |
| try { | |
| const repoResult = await github.rest.search.repos({ | |
| q: `topic:artificial-intelligence created:>${sinceDate} stars:>50`, | |
| sort: 'stars', | |
| order: 'desc', | |
| per_page: 10 | |
| }); | |
| trendingRepos = (repoResult.data.items || []).slice(0, 10); | |
| } catch (e) { | |
| console.log('GitHub repo search failed:', e.message); | |
| } | |
| // --- 2. GitHub 热门 AI 相关仓库(近期活跃,高星标) --- | |
| let hotRepos = []; | |
| try { | |
| const hotResult = await github.rest.search.repos({ | |
| q: `AI OR LLM OR GPT OR "machine learning" pushed:>${sinceDate} stars:>1000`, | |
| sort: 'updated', | |
| order: 'desc', | |
| per_page: 10 | |
| }); | |
| hotRepos = (hotResult.data.items || []).slice(0, 10); | |
| } catch (e) { | |
| console.log('GitHub hot repo search failed:', e.message); | |
| } | |
| // --- 3. Hacker News 热门 AI 相关文章 --- | |
| let hnStories = []; | |
| try { | |
| const topRes = await fetch('https://hacker-news.firebaseio.com/v0/topstories.json'); | |
| if (!topRes.ok) throw new Error(`HTTP ${topRes.status}`); | |
| const topIds = await topRes.json(); | |
| const candidates = topIds.slice(0, 80); | |
| const storyPromises = candidates.map(async (id) => { | |
| try { | |
| const res = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`); | |
| if (!res.ok) return null; | |
| return res.json(); | |
| } catch { return null; } | |
| }); | |
| const stories = (await Promise.all(storyPromises)).filter(Boolean); | |
| const aiKeywords = /\b(ai|llm|gpt|openai|claude|gemini|anthropic|deepseek|mistral|llama|transformer|diffusion|machine.?learning|deep.?learning|neural|agi|copilot|chatbot|generative|foundation.?model|sora|midjourney|stable.?diffusion|hugging.?face|fine.?tun(?:e|ing)|rag|vector.?db|embedding|multimodal|reasoning|agent|mcp)\b/i; | |
| hnStories = stories | |
| .filter(s => s && s.title && aiKeywords.test(s.title)) | |
| .sort((a, b) => (b.score || 0) - (a.score || 0)) | |
| .slice(0, 10); | |
| } catch (e) { | |
| console.log('Hacker News fetch failed:', e.message); | |
| } | |
| // --- 构建 Issue 内容 --- | |
| const truncate = (s, max = 100) => s ? s.substring(0, max) : '暂无描述'; | |
| let body = `> 🤖 本日报由 GitHub Actions 自动生成,数据来源:GitHub Trending + Hacker News\n`; | |
| body += `> 📅 数据范围:${sinceDate} ~ ${todayStr}\n\n`; | |
| // Hacker News 部分 | |
| body += `## 🔥 AI 科技热点(Hacker News)\n\n`; | |
| if (hnStories.length > 0) { | |
| hnStories.forEach((s, i) => { | |
| const url = s.url || `https://news.ycombinator.com/item?id=${s.id}`; | |
| const hnLink = `https://news.ycombinator.com/item?id=${s.id}`; | |
| body += `${i + 1}. **[${s.title}](${url})** — ⬆️ ${s.score || 0} 分 | 💬 [${s.descendants || 0} 条评论](${hnLink})\n`; | |
| }); | |
| } else { | |
| body += `_本周暂无匹配的 AI 相关热点文章。_\n`; | |
| } | |
| // GitHub 新项目部分 | |
| body += `\n## 🌟 本周新星 AI 项目(GitHub)\n\n`; | |
| if (trendingRepos.length > 0) { | |
| trendingRepos.forEach((r, i) => { | |
| body += `${i + 1}. **[${r.full_name}](${r.html_url})** ⭐ ${r.stargazers_count} — ${truncate(r.description)}\n`; | |
| }); | |
| } else { | |
| body += `_本周暂无匹配的新项目。_\n`; | |
| } | |
| // GitHub 活跃项目部分 | |
| body += `\n## 🚀 近期活跃 AI 项目(GitHub)\n\n`; | |
| if (hotRepos.length > 0) { | |
| hotRepos.forEach((r, i) => { | |
| body += `${i + 1}. **[${r.full_name}](${r.html_url})** ⭐ ${r.stargazers_count} — ${truncate(r.description)}\n`; | |
| }); | |
| } else { | |
| body += `_本周暂无匹配的活跃项目。_\n`; | |
| } | |
| body += `\n---\n`; | |
| body += `_💡 如需调整关键词或推送频率,请编辑 \`.github/workflows/ai-daily-digest.yml\`_\n`; | |
| // --- 创建 Issue --- | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: `📰 AI 科技日报 — ${todayStr}`, | |
| body: body, | |
| labels: ['daily-digest'] | |
| }); | |
| console.log(`Daily digest issue created for ${todayStr}`); |