代码拉取完成,页面将自动刷新
Tagup 是一款简易的Webhook工具,通过添加标签(tag)实现在服务端自动更新(克隆)代码。简单配置即可运行。支持GitHub, GitLab, Gitee, Gogs, Gitea。
全局安装,在命令行中使用
npm i tagup -g
当做程序依赖包使用
npm i tagup
tagup [command] [options]
例如:
tagup start -d /home/foo -p 8000
可以通过 tagup -h
查看可用参数。
-v, --version 显示版本
start [options] 启动tagup服务
stop <id> 停止tagup
list 查看正在运行的tagup服务列表
help [start|stop|list] 显示命令可用参数
tagup start -h
:
-f, --file <type> 通过配置文件启动服务,通过require获取文件内容(支持json、js)
-i, --id <type> 启动服务的唯一标识,默认自动生成
-d, --dir <type> 仓库所在的根目录(绝对路径)(必填项)
-p, --port <type> 启动服务的端口,默认自动选择
-s, --secret <type> Webhook中设置的秘钥
-U, --username <type> git登录用户名(通过http克隆代码)
-P, --password <type> git登录密码(通过http克隆代码)
-pa, --path <type> URL的路径,默认:/webhook
-c, --cmd <type> 获取代码并切换到对应的标签后执行的命令
-D, --daemon 开启常驻进程和守护进程
-h, --help 显示可用命令
通过NPM安装tagup
后,在代码中可以这样使用:
const tagup = require('tagup');
// 或者在typescript中
// import tagup from 'tagup';
const options = {
dir: '/home/foo',
port: 8000
};
tagup(options);
dir
: 仓库存放的目录,必须是绝对路径。必选参数port
: 启动服务的端口,默认自动选择secret
: Webhook中设置的秘钥username
: git登录用户名(通过http克隆代码)password
: git登录密码(通过http克隆代码)path
: URL的路径,默认:/webhookcmd
: 获取代码并切换到对应的标签后执行的命令下面以GitHub为例:
tagup -d /home/foo -p 8000 -s 123456
Settings
- Webhooks
- Add webhook
http(s)://ip:8000/webhook
(ip为启动的服务所在的服务器的ip,如果使用了代理则输入代理的地址。必须确保URL路径为 /webhook
)123456
Branch or tag creation
(确保有Tag push event)Active
Add webhook
保存dir
)有写入权限git clone [url]
)username
和password
username
和password
,会执行git clone url
username
和password
后,会使用http或https方式获取代码,此时会将username
和password
拼入url中,并且克隆的项目中 .git/config 文件中可以查看到账号密码。v1.0
或 v1.2.3
或 v1.2.3.4
npm install
,之后再执行参数cmd
中的命令(如果cmd
参数不存在则会检测package.json中的scripts中是否包含restart
,如果存在则执行npm run restart
)此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型