feat: automate CD via GitHub self-hosted runner on ECS - #3
Open
qiaolei1973 wants to merge 1 commit into
Open
Conversation
Adds a self-hosted runner-based deploy job so that pushing to main triggers build + automated deployment to the ECS k3s cluster without any manual SSH steps. - .github/workflows/deploy.yml: add `deploy` job (runs-on: self-hosted, ecs) that checks out the repo, optionally syncs UPSTREAM_API_KEY from GitHub Secrets, and runs deploy-remote.sh; gated by `environment: production` - scripts/setup-runner.sh: one-shot script to download, register, and install the GitHub Actions runner as a systemd service (NAT-friendly pull model, `npm run ecs:runner`) - scripts/deploy-remote.sh: replace hardcoded `latest` image tag with IMAGE_TAG env var (default: latest) so workflow_dispatch with a custom tag works end-to-end - package.json: add `ecs:runner` and `ecs:rollback` convenience scripts Closes #2 Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
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 Self-hosted Runner 的自动化 CD,push main 后无需任何手动 SSH 操作即可自动部署到 ECS k3s 集群。关联 #2。
deployjob:依赖buildjob 成功后运行,runs-on: [self-hosted, ecs],先从 GitHub Secrets 同步UPSTREAM_API_KEY(若已配置),再调用deploy-remote.sh完成部署scripts/setup-runner.sh:一次性初始化脚本,下载 Actions runner 二进制、注册到 GitHub、以 systemd 服务启动(Pull 模式,无需开放入站端口,天然兼容 NAT 环境)。通过npm run ecs:runner调用deploy-remote.sh:将三处硬编码的:latest替换为$IMAGE_TAG(默认latest),使workflow_dispatch自定义 tag 能端到端生效package.json:新增ecs:runner(安装 runner)和ecs:rollback(一键回滚)便捷脚本ECS 一次性初始化
测试计划
build和deployjob 均成功k3s kubectl get pods -n system确认 Pod 正常运行且镜像为最新workflow_dispatch指定image_tag=v1.0.0,确认 Pod 使用对应 tagUPSTREAM_API_KEYGitHub Secret 后重新部署,确认 k8s Secret 同步更新npm run ecs:rollback,确认 Pod 回滚到上一个 revision🤖 Generated with Claude Code