Repository navigation
ci: 接入 GitHub Actions(CI + 自动部署) - #1
Merged
Merged
Conversation
- ci.yml:前端 tsc/vite 构建 + 后端 mvn test(测试用 H2,无需 MySQL)+ 打包校验 - deploy.yml:push main 自动部署到 ECS,走阿里云 Cloud Assistant 而非 SSH (Actions runner 属境外出口,直连 22 端口会被上游丢包,Cloud Assistant 走 HTTPS API) - deploy/deploy-java.sh:幂等部署脚本,含前置校验、备份回滚点、 AutoLoginService 打包校验(缺类则不重启服务)、免登录契约验证 部署后自动外网复验首页与免登录接口,结果写入 job summary。
workflow 里内联的多行 python3 -c 必须顶格写,会顶断 run: | 块标量的缩进, 导致 GitHub 无法解析 YAML。改为把解析逻辑抽到 deploy/ca_result.py。 已用真实 RunCommand 返回验证 status / output 两种模式均正确。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
内容
.github/workflows/ci.yml:CI(前端构建 + 后端测试/产物校验).github/workflows/deploy.yml:push main 后自动部署到 ECSdeploy/deploy-*.sh:幂等部署脚本,含前置校验、备份回滚点、部署后契约验证deploy/ca_result.py:解析 Cloud Assistant 返回(避免内联多行 Python 顶断 YAML 缩进)部署通道
不走 SSH,走阿里云 Cloud Assistant(
aliyun ecs RunCommand)。原因:GitHub Actions runner 与开发机同属境外出口,直连
47.93.15.207:22会被阿里云上游静默丢包(已实测nc超时),安全组规则在该层之下,加了也不生效。Cloud Assistant 走 HTTPS API,已用最小权限 RAM 子账号实测可正常下发执行。凭据
ecs-deploy-ci+ 自定义策略ecs-deploy-minimal,仅授予ecs:RunCommand/ecs:DescribeInvocationResults/ecs:DescribeInstancesALIYUN_AK/ALIYUN_SK),明文不入库合并后行为
deploy workflow 监听
main,合并即自动部署:java(systemd)、python(PM2)、node(静态 + nginx)。每次约 30 秒重启,脚本幂等且带备份回滚点。本 PR 合并前不会触碰线上。