CI/CD 实战学习路线(精简版)
阶段1:GitHub Actions CI(自动 test)
- GitHub Actions 官方:https://docs.github.com/en/actions
内容:理解 workflow(yaml)、job/step、触发器(push/PR),实现自动跑 test 的 CI。 - Quickstart:https://docs.github.com/en/actions/writing-workflows/quickstart
内容:10分钟搭建最小 CI(checkout + install + test)。
阶段2:PR gate(lint + test + review)
- Branch protection:https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/about-protected-branches
内容:设置 main 分支保护,强制 CI 通过 + code review 才能 merge。 - lint 工具(示例 ESLint):https://eslint.org/
阶段3:Docker build(标准化产物)
- Docker 入门:https://docs.docker.com/get-started/
内容:镜像/容器概念,构建可运行环境。 - Dockerfile 参考:https://docs.docker.com/reference/dockerfile/
内容:如何把应用打包成一致运行环境(CI 产物标准化)。
阶段4:CD(自动部署 VPS)
-
GitHub SSH deploy action:https://github.com/appleboy/ssh-action
内容:通过 GitHub Actions SSH 登录服务器执行部署脚本。 -
Docker Compose:https://docs.docker.com/compose/
内容:服务器端用 compose 管理服务(拉镜像 + 重启应用)。
阶段5:工程化(secrets / 多环境 / rollback)
-
Secrets 管理:https://docs.github.com/en/actions/security-guides/encrypted-secrets
内容:安全存储 SSH key、API key 等。 -
多环境部署:https://docs.github.com/en/actions/deployment/about-deployments/deploying-with-github-actions
内容:dev / staging / prod 分环境流水线。 -
Matrix builds:https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
内容:多版本并行测试(如 Node/Python 多版本)。