gitlink-cli/.devops/gitlink-cli.yml

42 lines
1.3 KiB
YAML

version: 2
name: jtx_gitlink_cli
description: "gitlink-cli 项目:代码提交时自动测试、构建并部署到服务器"
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: 测试并部署到服务器
task: ssh_cmd@1.1.1
input:
ssh_pass: ((jtx_gitlink_cli.jtx_gitlink_cli_ssh))
ssh_ip: '"121.41.212.97"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: >-
"cd /root && rm -rf gitlink-cli && git clone --depth=1 https://gitlink.org.cn/jiangtx/gitlink-cli.git && cd gitlink-cli && docker run --rm -v $(pwd):/build -w /build docker.1ms.run/library/golang:1.26-alpine go test ./... && docker build --no-cache -t gitlink-cli . && (docker stop gitlink-cli || true) && (docker rm gitlink-cli || true) && docker run -d --restart=always --name gitlink-cli gitlink-cli version"
needs:
- git_clone_0
- ref: end
name: 结束
task: end
needs:
- ssh_cmd_0