Skip to content

feat: add deployment automation - #4233

Closed
forecho wants to merge 1 commit into
QuantumNous:mainfrom
richcalls:feat/deploy-automation
Closed

feat: add deployment automation#4233
forecho wants to merge 1 commit into
QuantumNous:mainfrom
richcalls:feat/deploy-automation

Conversation

@forecho

@forecho forecho commented Apr 14, 2026

Copy link
Copy Markdown

Summary

  • 添加后端 CI/CD:Go 编译 + SSH 部署,失败自动回滚
  • 添加前端 CI/CD:Cloudflare Pages 自动部署
  • 添加部署脚本:首次部署(Nginx + SSL)和更新部署
  • 添加 systemd 服务、Nginx 反向代理模板、.env.example
  • 添加部署文档(含扩展从节点指南)
  • 删除不需要的上游 workflow(Docker、Electron、Gitee 同步等)

Test plan

  • 首次部署到 hetzner 服务器
  • 验证 CI 自动触发
  • 验证 SSL 证书申请
  • 验证失败回滚机制

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Refactored CI/CD pipelines for streamlined backend and frontend deployment automation
    • Added deployment infrastructure including systemd service configuration, Nginx reverse proxy setup, and automated deployment scripts
    • Removed legacy Docker, Electron build, and external sync workflows
    • Added operational tooling for service monitoring, logging, and upstream synchronization

- Add backend CI/CD: Go build + deploy via SSH, auto-rollback on failure
- Add frontend CI/CD: Cloudflare Pages deployment
- Add deploy scripts: first-time setup (Nginx + SSL) and update deploy
- Add systemd service, Nginx reverse proxy template, .env.example
- Add deployment documentation with scaling guide
- Remove unused upstream workflows (Docker, Electron, Gitee sync, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7235c98-a676-42fe-b2b9-e216fa575dcd

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8661d and 0075def.

📒 Files selected for processing (15)
  • .github/workflows/deploy-backend.yml
  • .github/workflows/deploy-web.yml
  • .github/workflows/docker-image-alpha.yml
  • .github/workflows/docker-image-arm64.yml
  • .github/workflows/electron-build.yml
  • .github/workflows/pr-check.yml
  • .github/workflows/release.yml
  • .github/workflows/sync-to-gitee.yml
  • deploy/.env.example
  • deploy/README.md
  • deploy/deploy-all.sh
  • deploy/deploy.sh
  • deploy/new-api.service
  • deploy/nginx-new-api.conf
  • makefile

Walkthrough

This PR removes legacy Docker image and release workflows while introducing two streamlined GitHub Actions pipelines (backend Go binary compilation with testing, and frontend Vite build). It adds complete server deployment automation infrastructure including systemd service configuration, Nginx reverse proxy setup, bash deployment scripts, and environment templates for managing the new-api backend service on Ubuntu servers.

Changes

Cohort / File(s) Summary
Removed CI/CD Workflows
.github/workflows/docker-image-alpha.yml, docker-image-arm64.yml, electron-build.yml, pr-check.yml, release.yml, sync-to-gitee.yml
Deleted six legacy GitHub Actions workflows covering Docker multi-arch builds, Electron app releases, PR quality checks, and Gitee synchronization. Consolidated into simpler backend/web deployment pipelines.
New Backend & Web Pipelines
.github/workflows/deploy-backend.yml, deploy-web.yml
Added two GitHub Actions workflows: backend pipeline runs Go tests and cross-compiles Linux AMD64 binary with version injection, triggering deployment on main branch pushes; frontend pipeline builds React/Vite app and deploys to Cloudflare Pages on main/PR changes.
Deployment Scripts & Service Config
deploy/deploy.sh, deploy/deploy-all.sh, deploy/new-api.service, deploy/nginx-new-api.conf
Added bash scripts implementing end-to-end server setup (binary installation, systemd unit creation, Nginx/SSL configuration) with rollback support, systemd service unit for new-api backend with auto-restart and journal logging, and Nginx reverse proxy template with SSL/HTTP2 and upstream proxy to backend.
Deployment Documentation & Templates
deploy/README.md, deploy/.env.example
Added comprehensive deployment guide covering architecture overview, CI automation flow, first-time setup steps, slave node configuration for multi-instance deployments, operational commands, environment variables, and troubleshooting. Added environment template specifying database, Redis, secrets, and node configuration.
Build Configuration
makefile
Replaced local dev workflow (frontend build + backend dev server) with production build-and-deploy toolchain. Added build target for cross-compiling Go binary, deploy target uploading artifacts and running remote deployment script, and operational targets (logs, status, restart, sync-upstream) for systemctl/journalctl SSH access.

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions
    participant Server as Ubuntu Server
    participant Systemd as systemd
    participant Nginx as Nginx
    participant Backend as new-api Backend
    participant Verify as Verification

    GHA->>GHA: Compile new-api binary
    GHA->>Server: SCP upload binary & deploy/ dir
    GHA->>Server: SSH execute deploy/deploy.sh
    
    Server->>Server: Validate binary & .env
    Server->>Server: Backup previous binary
    Server->>Server: Create new-api user/dirs
    Server->>Systemd: Install/reload service unit
    
    alt First Deploy with Domain
        Server->>Server: Generate/update Nginx config
        Server->>Server: Run certbot for SSL certs
    end
    
    Server->>Systemd: Start new-api service
    Systemd->>Backend: Execute /opt/new-api/new-api
    Systemd->>Systemd: Load .env environment
    
    Server->>Nginx: Reload configuration
    Nginx->>Nginx: Verify SSL certs & config
    
    Server->>Verify: Check port listening (ss)
    Verify->>Nginx: HTTPS request to /api/status
    Nginx->>Backend: Proxy request
    Backend->>Verify: Response
    
    Verify->>Server: Verification complete
    Server->>GHA: Deployment success/failure
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • #2013: Deletes .github/workflows/docker-image-alpha.yml which this PR also removes entirely as part of workflow consolidation.
  • #2022: Modifies .github/workflows/docker-image-arm64.yml that this PR deletes, indicating overlapping Docker CI/CD infrastructure refactoring.
  • #2008: Touches Docker image workflow files being removed here, suggesting related CI/CD architecture changes.

Poem

🐰 Workflows simplified, scripts in place,
Systemd and Nginx join the race,
Deploy with ease from push to prod,
Our new pipeline? Quite the mod! 🚀

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@forecho forecho closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant