使用 Bun + TypeScript 同步多个 GitHub 仓库的 Release assets 到 SiFli 内部对象存储。
- 支持在
mirror.config.json中配置多个 GitHub 仓库。 - 支持手工指定必须同步的
manualTags。 - 每周自动扫描新的正式 Release,并同步带资产的 tag。
- 同步成功后自动更新
master分支上的syncedTags。 - COS 路径固定为
github_assets/<org>/<repo>/releases/download/<tag>/<asset-name>。
根目录的 mirror.config.json 格式如下:
{
"version": 1,
"repos": [
{
"owner": "OpenSiFli",
"repo": "crosstool-ng",
"manualTags": [
"14.2.0-20250221"
],
"syncedTags": [],
"flushUrl": null
}
]
}字段说明:
manualTags: 手工指定、必须补同步的 tag。syncedTags: 已成功同步到 COS 的 tag,由工作流自动维护。flushUrl: 可选 CDN 刷新路径;不需要时填null。
工作流文件为 .github/workflows/mirror-sync.yml,触发方式:
push到master:补同步manualTags中尚未同步的 tag。schedule:每周一北京时间 01:00 检测新的正式 Release。workflow_dispatch:手工触发,仅处理manualTags中尚未同步的 tag。
需要在 GitHub 仓库中配置以下 Secrets:
COS_DOWNLOAD_SECRET_IDCOS_DOWNLOAD_SECRET_KEYCOS_DOWNLOAD_REGIONCOS_DOWNLOAD_BUCKET
可选:
GH_TOKEN: 如果需要更高 GitHub API 额度或访问私有仓库,可额外配置。未提供时默认使用GITHUB_TOKEN。
bun install
bun run typecheck
bun test生成计划:
bun run src/cli.ts plan --config mirror.config.json --mode schedule下载单个 release 的全部资产到本地:
bun run src/cli.ts download \
--owner OpenSiFli \
--repo crosstool-ng \
--tag 14.2.0-20250221 \
--output-root .mirror-work/assets把成功同步的 tag 写回配置:
bun run src/cli.ts apply-state \
--config mirror.config.json \
--tasks-json '[{"owner":"OpenSiFli","repo":"crosstool-ng","tag":"14.2.0-20250221","flushUrl":null,"reason":"manual"}]' \
--write