forked from Gitlink/gitlink-cli
42 lines
1.9 KiB
YAML
42 lines
1.9 KiB
YAML
version: 2
|
||
name: gitlink_web_deploy
|
||
description: "gitlink-web 科研服务:master 合并后仅同步代码并重启服务(不触碰 systemd 单元与 API_KEY,密钥由 deploy.py 一次性配在服务器上)"
|
||
trigger:
|
||
webhook: gitlink@1.0.0
|
||
event:
|
||
- ref: push
|
||
ruleset-operator: AND
|
||
global:
|
||
concurrent: 1
|
||
workflow:
|
||
- ref: start
|
||
name: 开始
|
||
task: start
|
||
- ref: git_clone_0
|
||
name: git clone
|
||
task: git_clone@1.2.9
|
||
input:
|
||
remote_url: '"https://gitlink.org.cn/jiangtx/gitlink-cli.git"'
|
||
ref: '"refs/heads/master"'
|
||
commit_id: '""'
|
||
depth: 1
|
||
needs:
|
||
- start
|
||
- ref: ssh_cmd_0
|
||
name: 同步代码并重启 gitlink-web
|
||
task: ssh_cmd@1.1.1
|
||
input:
|
||
ssh_ip: '"121.41.212.97"'
|
||
ssh_port: '"22"'
|
||
ssh_user: '"root"'
|
||
ssh_pass: ((gitlink_cli.wyx_ssh_pass))
|
||
ssh_cmd: >-
|
||
"set -e && cd /root && rm -rf gitlink-cli && git clone --depth=1 -b master https://gitlink.org.cn/jiangtx/gitlink-cli.git && echo '>>> 1. 同步代码(gitlink-web → /opt/gitlink-web,不动 systemd 与 API_KEY)' && mkdir -p /opt/gitlink-web/{templates,skills,reports} && cp -rf gitlink-cli/gitlink-web/* /opt/gitlink-web/ && echo '>>> 2. 更新 Python 依赖' && cd /opt/gitlink-web && pip3 install -r requirements.txt -q 2>&1 | tail -3 && echo '>>> 3. 重启服务(沿用既有 systemd 单元,API_KEY 已在服务器上)' && systemctl restart gitlink-web && sleep 3 && echo '>>> 4. 健康检查' && (curl -fsS http://127.0.0.1/skills/ -o /dev/null && echo '✅ 服务已更新上线:http://121.41.212.97/skills/' || (echo '⚠️ 健康检查失败,若首次部署需先跑 gitlink-web/deploy.py 配好 API_KEY 与 systemd 单元' && systemctl status gitlink-web --no-pager -l | head -20)) && echo '>>> 5. 最近日志' && journalctl -u gitlink-web -n 5 --no-pager"
|
||
needs:
|
||
- git_clone_0
|
||
- ref: end
|
||
name: 结束
|
||
task: end
|
||
needs:
|
||
- ssh_cmd_0
|