forked from Gitlink/gitlink-cli
114 lines
2.3 KiB
Markdown
114 lines
2.3 KiB
Markdown
# GitLink Workflow 服务器部署指南
|
||
|
||
本文档描述如何将 workflow 引擎部署到 Linux 服务器,使用 systemd timer 实现 24×7 自动化运行。
|
||
|
||
## 部署步骤
|
||
|
||
### 1. 编译
|
||
|
||
```bash
|
||
GOOS=linux GOARCH=amd64 go build -buildvcs=false -o gitlink-cli .
|
||
```
|
||
|
||
### 2. 上传
|
||
|
||
```bash
|
||
scp gitlink-cli root@39.108.139.73:/usr/local/bin/
|
||
scp -r skills/ root@39.108.139.73:/etc/gitlink-cli/skills/
|
||
```
|
||
|
||
### 3. 登录配置
|
||
|
||
```bash
|
||
ssh root@39.108.139.73
|
||
gitlink-cli config set anthropic-api-key sk-ant-xxx
|
||
gitlink-cli auth login
|
||
```
|
||
|
||
### 4. 创建 systemd service
|
||
|
||
以 `contributor-growth` 工作流为例:
|
||
|
||
```bash
|
||
cat > /etc/systemd/system/gitlink-contributor.service << 'EOF'
|
||
[Unit]
|
||
Description=GitLink Workflow: contributor-growth
|
||
After=network-online.target
|
||
|
||
[Service]
|
||
Type=oneshot
|
||
ExecStart=/usr/local/bin/gitlink-cli workflow +run \
|
||
--name contributor-growth \
|
||
--owner chroe --repo gitlink-cli \
|
||
--format json
|
||
User=root
|
||
EOF
|
||
```
|
||
|
||
### 5. 创建 systemd timer
|
||
|
||
```bash
|
||
cat > /etc/systemd/system/gitlink-contributor.timer << 'EOF'
|
||
[Unit]
|
||
Description=GitLink Contributor Growth — daily
|
||
|
||
[Timer]
|
||
OnCalendar=daily
|
||
Persistent=true
|
||
|
||
[Install]
|
||
WantedBy=timers.target
|
||
EOF
|
||
```
|
||
|
||
### 6. 启动
|
||
|
||
```bash
|
||
systemctl daemon-reload
|
||
systemctl enable --now gitlink-contributor.timer
|
||
```
|
||
|
||
### 7. 验证
|
||
|
||
```bash
|
||
systemctl status gitlink-contributor.timer
|
||
journalctl -u gitlink-contributor.service -f
|
||
```
|
||
|
||
## 多工作流部署
|
||
|
||
每个工作流需要独立的 service 和 timer 文件。例如同时运行社区运营和贡献者成长:
|
||
|
||
```bash
|
||
# community-ops
|
||
cat > /etc/systemd/system/gitlink-community.service << 'EOF'
|
||
[Unit]
|
||
Description=GitLink Workflow: community-ops
|
||
After=network-online.target
|
||
[Service]
|
||
Type=oneshot
|
||
ExecStart=/usr/local/bin/gitlink-cli workflow +run \
|
||
--name community-ops --owner chroe --repo gitlink-cli --format json
|
||
User=root
|
||
EOF
|
||
|
||
cat > /etc/systemd/system/gitlink-community.timer << 'EOF'
|
||
[Unit]
|
||
Description=GitLink Community Ops — every 5m
|
||
[Timer]
|
||
OnCalendar=*:0/5
|
||
Persistent=true
|
||
[Install]
|
||
WantedBy=timers.target
|
||
EOF
|
||
|
||
systemctl enable --now gitlink-community.timer
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
- 确保服务器上 `gitlink-cli` 已通过 `auth login` 认证
|
||
- `ANTHROPIC_API_KEY` 可通过环境变量或配置文件设置
|
||
- 使用 `journalctl -u <service> -f` 查看实时日志
|
||
- Timer 的 `OnCalendar` 语法参考 systemd.time(7) 手册
|