Files
xmwork/.claude/commands/add-ci.md
T
gongzhiyong bc7f53790e feat: add team agent library (3 slash commands + 2 specialist agents)
Commands (.claude/commands/):
- /audit-deps [repo|all]    — CVE + outdated deps audit with risk ranking
- /add-ci <repo>            — add GitHub Actions CI matching repo's stack
- /review-pr <pr>           — deep PR review, comment-only (no auto-approve)

Specialist agents (.claude/agents/):
- casdoor-specialist        — Go/Beego expert, upstream fork safety
- lobechat-brand-guardian   — protect 242 locale de-branding on rebase

README.md: add '团队可以/应该写什么' section
 - categorizes 6 types of content for ai-ops
 - specifies PR flow, reviewer checklist, refresh mechanism

.gitignore: exclude .claude/settings.local.json and reports/
2026-04-23 23:36:24 +08:00

2.4 KiB
Raw Blame History

description, argument-hint
description argument-hint
给指定仓库补 GitHub Actions CI workflow,参考同栈仓库的既有风格 <repo-name>

给仓库 $1 补一个 GitHub Actions CI workflow。参数必填。

第一步:识别仓库类型

读 /workspace/$1/ 下的核心文件判断栈:

证据 类型 参考模板
requirements.txt + main.py 且含 FastAPI Python FastAPI chat-gw/.github/workflows/main_gaw-chat-tools.yml
package.json 含 "@nestjs/core" NestJS gongdan/.github/workflows/backend-deploy.yml
go.mod 且含 beego/beego Go Beego casdoor-internal/.github/workflows/build.yml
package.json 含 "next" Next.js lobechat-enterprise/.github/workflows/deploy-aca.yml

第二步:照抄同栈仓库的 CI 风格

不要凭空造 —— 读对应参考模板,复用:

  • action 版本(如 actions/setup-python@v5)
  • 缓存策略(pip / npm / go mod 的 cache key 格式)
  • 作业命名习惯
  • secrets 引用方式

第三步:CI 内容必须包含

  1. Lint —— Python ruff + black、Node eslint + prettier、Go go vet + golangci-lint
  2. Unit test —— 各仓库的标准测试命令(见 ai-ops CLAUDE.md 的"测试/构建"表)
  3. Build 验证 —— docker compose build 或 go build 或 npm run build
  4. DB migration 一致性(如果有 Alembic/Prisma)—— 跑 alembic check 或 prisma validate
  5. Service containers(如果测试需要)—— PostgreSQL / Redis 用 GHA services

第四步:权限和触发

  • on: [pull_request, push-to-main]
  • permissions: contents: read, pull-requests: write
  • concurrency 取消重复运行

第五步:本地验证

不能真跑 GitHub Actions,但要:

  1. gh workflow list 确认新 workflow 能被识别
  2. 用 act 或手工核对 YAML:python -c "import yaml; yaml.safe_load(open('.github/workflows/ci.yml'))"
  3. 把各仓库的核心 test 命令在容器内跑一遍确保不挂

第六步:提 PR

  • 分支名:chore/add-ci-workflow
  • PR 标题:chore(ci): add GitHub Actions CI workflow
  • PR 描述必须列:使用了哪个参考模板、跑了哪些本地验证、预计 CI 时长

红线

  • ❌ 不要动 deploy workflow(deploy*.yml、build-and-deploy.yml)
  • ❌ 不要在 CI 里装 secrets 明文
  • ❌ 不要让 CI 自动 push commit(只报告,不改码)