cexll/swoole-webhook

Using WebHooks to automatically pull code

1.0.1 2022-08-13 14:41 UTC

This package is auto-updated.

Last update: 2024-04-13 18:18:15 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Using WebHooks to automatically pull code

Support

  • GitHub
  • Gitee

Require

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

Install

composer create-project cexll/swoole-webhook

Configure

  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:Server的配置

设置 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/github or http://ip:port/gitee

Secret/PassWord:对应config.json中的secret/password

Start

php run.php

License

Apache License Version 2.0, http://www.apache.org/licenses/