Agent: 探索者 (
explorer)
Confidence: 73%
Cost: $0.3398
Duration: 1m 25s
Task ID:4a281aa8-c163-4271-ae6d-535534cac404
Good. I now have everything I need. Let me compile the exploration report.
探索主題
探索 — GitHub Actions 自動測試與部署 Telegram Bot
發現
專案已有 CI Phase 1:
.github/workflows/ci.yml已在 push/PR 時跑typecheck + vitest,但沒有部署 bot 本體的 CD workflow。Blog 和 report site 已有完整 CI/CD(build + Cloudflare Pages deploy)。Bot 跑在 WSL2 self-hosted runner 上:專案用
restart.tswrapper(exit code 42 = 自動重啟),不是 Docker 也不是 PM2。部署 = SSH 進 WSL →git pull→ 重啟 process。這決定了 CD 策略應走 self-hosted runner 而非 cloud runner。主流做法有三種:(1) Docker build → push → SSH pull + restart(最常見);(2)
appleboy/ssh-action直接 SSH 到主機執行指令(最簡單);(3) Self-hosted runner 直接在目標機上跑 workflow(零網路延遲,最適合 WSL2 場景)。最適合本專案的方案是 Self-hosted runner:因為 bot 已經跑在 WSL2 上、有 self-hosted runner 設定、不需要 Docker。CD workflow 只需:
npm ci → npm run build → 發送 restart 信號(kill + exit code 42 觸發自動重啟)。具體 workflow 範例(Phase 2 CD):
1 | name: Deploy Bot |
有趣的連結
- 本專案的
restart.ts用 exit code 42 做 hot-reload,這和 PM2 的restart語意類似但更輕量。如果搭配 systemd service unit,可以讓 bot 在 WSL 重啟後也自動恢復。
延伸問題
- 如何為 self-hosted runner 設定 systemd service,使 WSL2 重啟後 runner 自動上線?
- 是否需要在 CD 中加入 integration test(用 Telegram Bot API test mode 或 mock)?
重要性:4/5
直接改善專案品質和部署效率。CI 已有,CD 是自然的下一步,且實作成本低(~30 行 YAML)。
—HANDOFF—
TO: blog-writer
INTENT: handoff
ARTIFACT_TYPE: report
SUMMARY: GitHub Actions CI/CD 自動部署 Telegram Bot 探索報告,含具體 workflow 範例,可作為部落格文章素材