原理

利用github自带的webhooks,对相关命令进行事件监控,一旦发生某项命令,执行对应的脚本。

方法一

delploy

脚本执行者必须有github的命令权限,最好以脚本身份执行一次命令。

    su xxx
    chmod +x file

方法二(2016-09-13)

go-webhook

apps.json

[
  {
    "name": "webhook",
    "script": "webhook",
    "args": [
      "--port=2987",
      "--hooks=/etc/hooks.json",
      "--verbose"
    ],
    "cwd": "/etc/",
    "one_launch_only": "true"
  }
]

hook.json

[
  {
    "id": "chenyunwen",
    "execute-command": "/opt/www/rose1988c.github.io/update.sh",
    "command-working-directory": "/opt/www/rose1988c.github.io"
  }
]

pm2 start apps.json

设置 webhook url = local:2987/webhook/chenyunwen