https://github.com/sy-records/git-deploy
🍭 Using WebHooks to automatically pull code.
https://github.com/sy-records/git-deploy
gitee github swoole webhook
Last synced: 10 months ago
JSON representation
🍭 Using WebHooks to automatically pull code.
- Host: GitHub
- URL: https://github.com/sy-records/git-deploy
- Owner: sy-records
- License: mit
- Created: 2020-06-15T06:16:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-25T07:31:18.000Z (over 2 years ago)
- Last Synced: 2025-04-15T15:13:18.518Z (10 months ago)
- Topics: gitee, github, swoole, webhook
- Language: PHP
- Homepage:
- Size: 36.1 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Git Deploy
[](//packagist.org/packages/sy-records/git-deploy) [](//packagist.org/packages/sy-records/git-deploy) [](//github.com/sy-records/git-deploy)
[](LICENSE)
🍭 Using WebHooks to automatically pull code.
## Support
* [x] GitHub
* [x] Gitee
* [x] Gitea
* [x] GitLab
## 依赖
* php >= 7.1
* ext-swoole (可以直接使用 [swoole-cli](https://github.com/swoole/swoole-src/releases/latest))
## 安装
```shell
composer create-project sy-records/git-deploy
```
## 配置
1. 修改配置文件`config.json`
`server`对应的是`Swoole\Http\Server`的相关配置
* `ip`:IP地址
* `port`:端口
* `mode`:启动模式 `SWOOLE_BASE/SWOOLE_PROCESS`
* `settings`:Server的配置
> 正式运行时需要启动守护进程,将`daemonize`修改为`1`
```json
"server": {
"ip": "0.0.0.0",
"port": 9666,
"mode": 1,
"settings": {
"worker_num": 1,
"daemonize": 0
}
},
```
`sites`对应的是项目的仓库等信息
分为`github`和`gitee`,`key`是仓库名称,支持多个仓库。
* `secret`/`password`:密钥/密码;`github`使用`secret`,`gitee`的 WebHook 密码使用`password`,签名密钥使用`secret`
* `ref`:分支
* `event_name`:事件名称;`github`为`push`,`gitee`为`push_hooks`
* `shells`:需要执行的脚本
```json
"sites": {
"github": {
"sy-records/git-deploy": {
"secret": "password",
"ref": "refs/heads/master",
"event_name": "push",
"shells": [
"git -C /yourpath/git-deploy pull"
]
}
},
"gitee": {
"sy-records/git-deploy": {
"password": "password",
"ref": "refs/heads/master",
"event_name": "push_hooks",
"shells": [
"git -C /yourpath/git-deploy pull"
]
}
},
"gitea": {
"sy-records/git-deploy": {
"secret": "password",
"ref": "refs/heads/master",
"event_name": "push",
"shells": [
"git -C /yourpath/git-deploy pull"
]
}
},
"gitlab": {
"sy-records/git-deploy": {
"secret": "password",
"ref": "refs/heads/master",
"event_name": "push",
"shells": [
"git -C /yourpath/git-deploy pull"
]
}
}
}
```
2. 填写WebHook
URL:`http://ip:port/github` or `http://ip:port/gitee`
Secret/PassWord:对应`config.json`中的`secret/password`
## 启动
```shell
php start.php
```
### systemd
```conf
[Unit]
Description=Git Depoly Service
After=network.target
[Service]
ExecStart=/usr/bin/php /workspace/git-deploy/start.php
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```