{"id":15285888,"url":"https://github.com/lifei6671/go-git-webhook","last_synced_at":"2025-04-06T23:18:44.942Z","repository":{"id":37430777,"uuid":"85376448","full_name":"lifei6671/go-git-webhook","owner":"lifei6671","description":"Golang 实现的自动化部署和运维工具，支持：Github / GitLab / GitOsc。","archived":false,"fork":false,"pushed_at":"2024-03-11T06:23:59.000Z","size":5099,"stargazers_count":221,"open_issues_count":4,"forks_count":85,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-30T21:09:40.062Z","etag":null,"topics":["beego","github","gitlab","gitlab-webhook","gogs","golang","webhook"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lifei6671.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-18T04:48:22.000Z","updated_at":"2025-03-23T08:26:01.000Z","dependencies_parsed_at":"2024-10-23T13:57:05.338Z","dependency_job_id":null,"html_url":"https://github.com/lifei6671/go-git-webhook","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":0.09482758620689657,"last_synced_commit":"7c7eebbd8bbcc13bce5f4032d9c31a9f7f06e70d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifei6671%2Fgo-git-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifei6671%2Fgo-git-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifei6671%2Fgo-git-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifei6671%2Fgo-git-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lifei6671","download_url":"https://codeload.github.com/lifei6671/go-git-webhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563942,"owners_count":20958971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beego","github","gitlab","gitlab-webhook","gogs","golang","webhook"],"created_at":"2024-09-30T15:08:10.841Z","updated_at":"2025-04-06T23:18:44.918Z","avatar_url":"https://github.com/lifei6671.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SmartWebHook\r\n\r\n[![Build Status](https://travis-ci.org/lifei6671/go-git-webhook.svg?branch=master)](https://travis-ci.org/lifei6671/go-git-webhook)\r\n[![Build status](https://ci.appveyor.com/api/projects/status/tpm2k23umrqri2dd/branch/master?svg=true)](https://ci.appveyor.com/project/lifei6671/go-git-webhook/branch/master)\r\n\r\n一个基于 Golang 开发的用于迅速搭建并使用 WebHook 进行自动化部署和运维系统，支持：Github / GitLab / GitOsc。\r\n\r\n界面和开发思路参考于 [git-webhook](https://github.com/NetEaseGame/git-webhook) 。\r\n\r\n在原作者的基础上解耦了WebHook和Server之间关系，实现了多对多关系。\r\n\r\n因与服务器通信使用的是SSH方式，请注意保管服务器账号和密码。\r\n\r\n同时支持 C/S 模式，配合[客户端](https://github.com/lifei6671/go-git-webhook-client/)可以实现不用SSH也可以远程执行命令。\r\n\r\n当使用 C/S 模式时，server 的账号和密码是服务器端跟 Client 第一次通信时的认证信息，服务器端将通过 http://remote url/token 地址换取连接 WebSocket 的密钥，该密钥会作为 `x-smarthook-token` 请求头发送到客户端进行认证连接。\r\n\r\n\r\n\r\n# 如何使用？\r\n\r\n## Docker \u0026 docker-compose\r\n\r\n[文档](./docs/docker.md)\r\n\r\n## 源码安装使用\r\n\r\n**1、拉取源码**\r\n\r\n```\r\ngit clone github.com/lifei6671/go-git-webhook.git\r\n\r\n```\r\n\r\n**2、编译源码**\r\n\r\n```\r\n#更新依赖\r\ngo get -d ./...\r\n\r\n#编译项目\r\ngo build -v -tags \"pam\" -ldflags \"-w\"\r\n```\r\n\r\n**3、配置**\r\n\r\n系统的配置文件位于 conf/app.conf 中：\r\n\r\n```ini\r\nappname = smartwebhook\r\n#监听的地址，如果要使用 nginx 作为前端代理\r\n#httpaddr = 127.0.0.1\r\n#监听的端口号\r\nhttpport = 8080\r\nrunmode = dev\r\nsessionon = true\r\n#保存到客户端的 session 名称\r\nsessionname = smart_webhook_id\r\ncopyrequestbody = true\r\n\r\n#生成回调地址时完整的域名\r\nbase_url = https://hook.iminho.me\r\n\r\n#时区设置\r\ntimezone = Asia/Shanghai\r\n\r\n#数据库配置\r\ndb_host=127.0.0.1\r\ndb_port=3306\r\ndb_database=webhook_db\r\ndb_username=root\r\ndb_password=123456\r\n\r\nqueue_size=50\r\n```\r\n\r\n请将 conf/的app.conf.example 重命名为 app.conf ，并修改 数据和端口号配置。\r\n\r\n**4、运行**\r\n\r\n```\r\nchmod 0777 go-git-webhook\r\n\r\n#恢复数据库，请提前创建一个空的数据库\r\n./go-git-webhook orm syncdb webhook\r\n\r\n#创建管理员账户\r\n./go-git-webhook install -account=admin -password=123456 -email=admin@163.com\r\n\r\n```\r\n\r\n# 注意\r\n\r\n## 添加 SSH Server\r\n\r\n- 当添加的是一台 SSH 方式的服务器时，Server IP 为SSH外网IP地址，端口号为SSH端口号，账号为登录账号，SSH Private Key 可以是密码也可以是登录密钥，系统会自动识别密码类型。\r\n\r\n- 如果添加的是一台 Client 模式的服务器时，Server IP 则为带有访问协议的网址，例如 `http://client.iminho.me`,端口号为HTTP端口号，如果为HTTP可是80，如果是HTTPS则是443. 账号和密码需要跟 Client 配置一致。\r\n\r\n## 添加 WebHook\r\n\r\n- WebHook 的回调脚本**暂**不支持换行，建议用服务器 shell 脚本代替命令。\r\n\r\n- 添加完 WebHook 后，会自动生成对应的url回调地址，将改地址填写到对应git服务的webhooks中即可。其中 `Secure` 字段暂时不支持。\r\n\r\n# 后台运行\r\n\r\n**使用nohup后台运行**\r\n\r\n```bash\r\nnohup ./go-git-webhook \u0026\r\n```\r\n\r\n\r\n**使用supervisor运行**\r\n\r\n```bash\r\n[program:go-git-webhook-client]\r\n#设置为你的程序工作目录，否则会找不到配置文件\r\ndirectory=/opt/go/src/github.com/lifei6671/go-git-webhook\r\ncommand=/opt/go/src/github.com/lifei6671/go-git-webhook/go-git-webhook\r\nautostart=true\r\nautorestart=true\r\nstartsecs=10\r\nstdout_logfile=/var/log/go-git-webhook/access.log\r\nstdout_logfile_maxbytes=1MB\r\nstdout_logfile_backups=10\r\nstdout_capture_maxbytes=1MB\r\nstderr_logfile=/var/log/go-git-webhook/error.log\r\nstderr_logfile_maxbytes=1MB\r\nstderr_logfile_backups=10\r\nstderr_capture_maxbytes=1MB\r\n\r\n```\r\n\r\n请将配置中的 `command` 配置为你服务器的实际程序地址\r\n\r\n\r\n# 使用 nginx 作为前端代理\r\n\r\n如果使用nginx 作为前端代理，需要配置 WebSocket 支持，具体配置如下：\r\n\r\n```smartyconfig\r\nserver {\r\n    listen       80;\r\n    server_name  webhook.iminho.me;\r\n\r\n    charset utf-8;\r\n    access_log  /var/log/nginx/webhook.iminho.me/access.log;\r\n\r\n    root \"/var/go/src/go-git-webhook\";\r\n\r\n    location ~ .*\\.(ttf|woff2|eot|otf|map|swf|svg|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {\r\n        root \"/var/go/src/go-git-webhook\";\r\n        expires 30m;\r\n    }\r\n    \r\n    # 这是为了配合任务执行时自动刷新任务状态，需要开启 WebSocket 支持，请将 proxy_pass 参数配置为你的服务地址\r\n    location /hook/scheduler/status {\r\n        proxy_pass http://127.0.0.1:8080;\r\n        proxy_redirect off;\r\n\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header Host $http_host;\r\n        proxy_set_header X-NginX-Proxy true;\r\n\r\n        proxy_http_version 1.1;\r\n        proxy_set_header Upgrade $http_upgrade;\r\n        proxy_set_header Connection \"upgrade\";\r\n    }\r\n    location / {\r\n        try_files /_not_exists_ @backend;\r\n    }\r\n    \r\n    # 这里为具体的服务代理配置\r\n    location @backend {\r\n        proxy_set_header X-Forwarded-For $remote_addr;\r\n        proxy_set_header Host            $http_host;\r\n        proxy_set_header   X-Forwarded-Proto $scheme;\r\n\r\n        proxy_pass http://127.0.0.1:8080;\r\n    }\r\n}\r\n\r\n```\r\n\r\n\r\n# 使用技术\r\n\r\ngo-git-webhook 基于beego框架1.7.2版本开发。编译于golang 1.8版本。使用glide作为包管理工具。\r\n\r\n# 界面预览\r\n\r\n![WebHook](https://github.com/lifei6671/go-git-webhook/blob/master/static/uploads/1.png?raw=true)\r\n\r\n![New WebHook](https://github.com/lifei6671/go-git-webhook/blob/master/static/uploads/2.png?raw=true)\r\n\r\n![WebHook And Server List](https://github.com/lifei6671/go-git-webhook/blob/master/static/uploads/4.png?raw=true)\r\n\r\n![New Server](https://github.com/lifei6671/go-git-webhook/blob/master/static/uploads/7.png?raw=true)\r\n\r\n![Scheduler List](https://github.com/lifei6671/go-git-webhook/blob/master/static/uploads/6.png?raw=true)\r\n\r\n# 问题反馈\r\n\r\n如发现 BUG 请在 [issues](https://github.com/lifei6671/go-git-webhook/issues) 中反馈。\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifei6671%2Fgo-git-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flifei6671%2Fgo-git-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifei6671%2Fgo-git-webhook/lists"}