cexll/swoole-webhook

使用WebHooks自动拉取代码

安装: 6

依赖项: 0

建议者: 0

安全: 0

星标: 6

关注者: 2

分支: 0

开放问题: 0

类型:项目

1.0.1 2022-08-13 14:41 UTC

This package is auto-updated.

Last update: 2024-09-13 19:11:28 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

使用WebHooks自动拉取代码

支持

  • GitHub
  • Gitee

要求

  • php >= 7.2
  • ext-swoole >= 4.5

安装

composer create-project cexll/swoole-webhook

配置

  1. 使用vim编辑config.json
"server": {
	"ip": "0.0.0.0",
	"port": 9501,
	"mode": 1,  // SWOOLE_BASE=1, SWOOLE_PROCESS=2
	"setting": {
		"worker_num": 1,
		"task_worker_num": 1,
		"task_enable_coroutine": true,
		"daemonize": true // 后台运行
	}
}

server对应的是Swoole\Http\Server的相关配置

  • ip:IP地址
  • port:端口
  • mode:启动模式 SWOOLE_BASE/SWOOLE_PROCESS
  • settings:服务器配置

设置 daemonize => true 时,程序将转入后台作为守护进程运行。长时间运行的服务器端程序必须启用此项。如果不启用守护进程,当ssh终端退出后,程序将被终止运行。

  1. sites对应的是项目的仓库等信息

分为githubgiteename是仓库名称,支持多个仓库。

  • secret/password:密钥/密码;github使用secretgitee的WebHook密码使用password,签名密钥使用secret
  • ref:分支
  • hook_name:事件名称;githubpushgiteepush_hooks
  • cmds:需要执行的脚本/命令
"sites": {
	"github": [{
		"name": "cexll/swoole-webhook",
		"secret": "password",
		"ref": "refs/heads/master",
		"hook_name": "push",
		"cmds": [
			"git -C /yourpath/project pull"
		]
	}],
	"gitee": [{
		"name": "cexll/swoole-webhook",
		"password": "password",
		"ref": "refs/heads/master",
		"hook_name": "push_hooks",
		"cmds": [
			"git -C /yourpath/project pull"
		]
	}]
}
  1. 填写WebHook

URL:http://ip:port/githubhttp://ip:port/gitee

密钥/密码:对应config.json中的secret/password

启动

php run.php

许可证

Apache License Version 2.0, https://apache.ac.cn/licenses/