Files
life-echo/.github/workflows/SETUP.md
iammm0 084075dcdb ci: 新增GitHub Actions CI/CD配置
- 新增.github/工作流配置
2026-01-26 11:54:20 +08:00

84 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速配置指南
## GitHub Secrets 配置清单
在 GitHub 仓库的 **Settings → Secrets and variables → Actions** 中添加以下 Secrets
### 必需配置
1. **SSH_PRIVATE_KEY**
- 描述SSH 私钥,用于连接到远程服务器
- 生成方法:
```bash
ssh-keygen -t ed25519 -C "github-actions"
cat ~/.ssh/id_ed25519 # 复制全部内容
```
- 将公钥添加到远程服务器:
```bash
cat ~/.ssh/id_ed25519.pub | ssh user@your-server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
```
2. **SSH_USER**
- 描述SSH 用户名
- 示例:`root`、`ubuntu`、`deploy`
3. **SSH_HOST**
- 描述:远程服务器 IP 或域名
- 示例:`192.168.1.100`、`example.com`
4. **ALIYUN_CR_USERNAME**
- 描述:阿里云容器镜像服务用户名
- 值:`zaikunxu`
5. **ALIYUN_CR_PASSWORD**
- 描述:阿里云容器镜像服务密码
- 值:`57ucV,g4LF2cqm8`
### 可选配置
6. **SSH_PORT**
- 描述SSH 端口默认22
- 示例:`22`、`2222`
7. **DEPLOY_PATH**
- 描述:远程服务器部署目录(默认:/opt/life-echo
- 示例:`/opt/life-echo`、`/home/deploy/life-echo`
## 镜像信息
- **镜像仓库地址**`crpi-u2903xccyzd6nqnc.cn-shanghai.personal.cr.aliyuncs.com`
- **命名空间**`huaga`
- **镜像名称**`lifecho-api`
- **完整镜像路径**`crpi-u2903xccyzd6nqnc.cn-shanghai.personal.cr.aliyuncs.com/huaga/lifecho-api:latest`
## 验证配置
配置完成后,推送代码到 `main`、`master` 或 `develop` 分支,工作流会自动触发。
或者手动触发:
1. 进入仓库的 **Actions** 标签页
2. 选择 **Docker Build and Deploy** 工作流
3. 点击 **Run workflow** 按钮
## 常见问题
### 1. 如何查看工作流执行日志?
- 进入 **Actions** 标签页,点击对应的运行记录查看详细日志
### 2. 如何测试 SSH 连接?
```bash
ssh -i ~/.ssh/id_ed25519 user@your-server
```
### 3. 如何测试 Docker 登录?
```bash
docker login crpi-u2903xccyzd6nqnc.cn-shanghai.personal.cr.aliyuncs.com \
--username=zaikunxu \
--password=57ucV,g4LF2cqm8
```
### 4. 部署失败怎么办?
- 检查 GitHub Actions 日志中的错误信息
- 确认远程服务器可以访问阿里云容器镜像服务
- 验证 SSH 连接和 Docker 权限