Skip to content

Sync Plugin Seed Data #10

Sync Plugin Seed Data

Sync Plugin Seed Data #10

# ---------------------------------------------------------------------------
# 插件种子数据自动同步
# 定期运行 scripts/search-deepseek-repos.mjs + scripts/sync-discussions.mjs 抓取
# 插件生态与讨论数据,再由 scripts/publish-cache.mjs 发布到 `cache` 孤儿分支
# (洁癖单 commit + force push,不污染 main 历史)。
# 前端从 raw.githubusercontent.com/{owner}/{repo}/cache/<file> 读取。
#
# 同步周期:每小时一次(cron "15 * * * *",每小时的第 15 分钟 UTC 触发)
# 选择理由:
# · star 数 / 新仓库 / 推送动态为小时级变化,每小时同步保持最及时
# · 单次运行 ~3 分钟(关键词 OR 合并 + 11 topic,per_page=100 分页,
# 2.1s 节流),24 次/天 ≈ 72 分钟/天,仍远低于免费额度 2000 分钟/月
# · 分钟数固定 23 分,避免与其它仓库的整点 cron 抢资源
# GitHub Search API 限额:带 token 30 req/min;脚本 OR 合并后单次请求量
# 大幅下降(9 关键词 → 2 组 OR + 11 topic),配额见底自动停止保底。
# ---------------------------------------------------------------------------
name: Sync Plugin Seed Data
on:
schedule:
- cron: "15 * * * *"
workflow_dispatch: {} # 手动触发(Actions 页面 "Run workflow")
# 允许 push cache 分支(contents: write)+ 读自家仓库 discussions(discussions: read)
permissions:
contents: write
discussions: read
concurrency:
group: sync-plugin-seed
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: 检出仓库
uses: actions/checkout@v7
with:
# 完整历史:publish-cache.mjs 依赖本地 git worktree / branch 操作
fetch-depth: 0
- name: 安装 pnpm
uses: pnpm/action-setup@v6
# ⚠️ 不写 version:pnpm 版本由 package.json 的 packageManager 字段
#(pnpm@11.20.0)精确指定,两处都写会报 "Multiple versions of pnpm specified"
- name: 安装 Node.js
uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 抓取插件与讨论数据
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 官方 deepseek-ai 讨论需个人 PAT(GITHUB_TOKEN 是 integration token,
# 无法读未安装 App 的外部仓库 discussions)
DEEPSEA_PAT: ${{ secrets.DEEPSEA_PAT }}
# 脚本照常写 scripts/output/*.json,供 publish:cache 读取。
# 默认参数:limit 1000/类型、star ≥ 10(查询语句 stars:>=10 过滤);
# 只收录官方指定 topic dsh-plugin;并发 6 + 全局限速 30 req/min。
run: pnpm search:plugins && pnpm sync:discussions
- name: 发布到 cache 分支(洁癖单 commit + force push)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm publish:cache