sy-records/git-deploy

Using WebHooks to automatically pull code.

Fund package maintenance!
donate.qq52o.me

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 0

Type:project

v1.1.1 2022-05-20 02:50 UTC

This package is auto-updated.

Last update: 2022-11-20 10:15:52 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

🍭 Using WebHooks to automatically pull code.

Support

  • GitHub
  • Gitee
  • Gitea
  • GitLab

依赖

  • php >= 7.1
  • ext-swoole

安装

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

"server": {
  "ip": "0.0.0.0",
  "port": 9666,
  "mode": 1,
  "settings": {
    "worker_num": 1,
    "daemonize": 0
  }
},

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

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

  • secret/password:密钥/密码;github使用secretgitee的 WebHook 密码使用password,签名密钥使用secret
  • ref:分支
  • event_name:事件名称;githubpushgiteepush_hooks
  • shells:需要执行的脚本
"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": {
    "git-deploy": {
      "secret": "password",
      "ref": "refs/heads/master",
      "event_name": "Push Hook",
      "shells": [
        "git -C /yourpath/git-deploy pull"
      ]
    }
  }
}
  1. 填写WebHook

URL:http://ip:port/github or http://ip:port/gitee

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

启动

php start.php