那我也分享一下现在正在用比较简易的 caddy 自动部署解决方案,可能没有 ci 之类的功能丰富,不过小项目,怎么快怎么来..(感觉非常方便,想给 caddy 10 个 star )
1. 安装带 git 插件的 caddy: `curl
getcaddy.com -sL |bash -s personal http.git`
2. 配置 caddyfile,放到项目的父目录(如果有多个项目,只需要开这一个 caddy 即可)
```
$ cat Caddyfile
http://0.0.0.0:9009 {
tls off
log stdout
# web 页面
git {
repo
[email protected]:example/example.git
path example
hook /example
key /root/.ssh/id_rsa
hook_type generic
branch master
then docker exec container_name npm run build # 重新 build 源码
then ./
do-something-else.sh }
git {
repo
[email protected]:example/example2.git
path example2
hook /example2
key /root/.ssh/id_rsa
hook_type generic
branch master
then docker exec container_name2 other command
}
}
```
3. 到项目的父目录去运行去`caddy`
4. github/gitlab 指定 webhook 地址 `
example.com:9009/example``
example.com:9009/example2`, 多个仓库以此类推
5. 招开发,更多人选择 DevOps,一份工资,几个人的工作量