{"id":13901333,"url":"https://github.com/LeoEatle/git-webhook-wework-robot","last_synced_at":"2025-07-17T21:33:04.592Z","repository":{"id":41773252,"uuid":"166331677","full_name":"LeoEatle/git-webhook-wework-robot","owner":"LeoEatle","description":"企业微信github/gitlab机器人","archived":false,"fork":false,"pushed_at":"2023-01-09T19:35:14.000Z","size":1918,"stargazers_count":289,"open_issues_count":26,"forks_count":79,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-25T03:06:44.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeoEatle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-18T02:39:47.000Z","updated_at":"2024-11-13T14:59:59.000Z","dependencies_parsed_at":"2023-02-08T13:46:16.489Z","dependency_job_id":null,"html_url":"https://github.com/LeoEatle/git-webhook-wework-robot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoEatle%2Fgit-webhook-wework-robot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoEatle%2Fgit-webhook-wework-robot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoEatle%2Fgit-webhook-wework-robot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoEatle%2Fgit-webhook-wework-robot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeoEatle","download_url":"https://codeload.github.com/LeoEatle/git-webhook-wework-robot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226305326,"owners_count":17603792,"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":[],"created_at":"2024-08-06T21:01:12.675Z","updated_at":"2024-11-25T09:31:15.077Z","avatar_url":"https://github.com/LeoEatle.png","language":"TypeScript","readme":"![git-webhook-wework-robot](https://socialify.git.ci/LeoEatle/git-webhook-wework-robot/image?description=1\u0026font=Raleway\u0026forks=1\u0026language=1\u0026logo=https%3A%2F%2Fwwcdn.weixin.qq.com%2Fnode%2Fwework%2Fimages%2FRtxThumb_2x.c70ae513d7.png\u0026owner=1\u0026pattern=Plus\u0026pulls=1\u0026stargazers=1\u0026theme=Light)\n\n\n\u003c!-- [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)\n[![docker build](https://img.shields.io/docker/automated/leoeatle/wxwork-git-robot)](https://cloud.docker.com/repository/docker/leoeatle/wxwork-git-robot/builds) --\u003e\n\n# 快速使用\n\n直接在git项目中配置webhook `https://service-d6if097q-1251767583.gz.apigw.tencentcs.com/release/wechat-work-gitlab-robot?id={robotid}`\n\n其中robotid是你的机器人id，可以在企业微信的机器人列表中查看，见图：\n\n\u003cimg src=\"./docs/wework-demo.jpg\" width=\"500\"\u003e\n\n# Changelog\n2020-10\n支持了 gitlab 的 review/wiki 事件\n\n2020-9\n支持了 gitlab 的腾讯云函数 git 机器人\n\nAPI网关地址: https://service-d6if097q-1251767583.gz.apigw.tencentcs.com/release/wechat-work-gitlab-robot?id={robotid}\n\n自建云函数、设置 webhook 请参考下面 github 的介绍，是一样。\n\n2020-1\n支持了腾讯云云函数的创建\n\n使用方式：\n在github中的`Webhook`配置 API 的网关地址：https://service-5mv1fv1k-1251767583.gz.apigw.tencentcs.com/release/wechatwork_git_robot?id={robotid}\n\n**注意：其中robotid是你需要推送的机器人id**\n\n\n自建云函数方式：\n1. `git clone https://github.com/LeoEatle/git-webhook-wework-robot.git`\n2. 注册并登陆腾讯云管理后台，新建一个云函数，可以先选个Node的Helloworld模板\n3. 将代码中的`cloud`目录上传，见图\n![](./docs/cloud1.png)\n\n4. 点击保存（保存后🉑️测试试试）\n\n5. 选择触发方式，添加新的触发方式，类型选择API网关，保存后得到url\n![](./docs/add_new.png)\n\n6. ok!可以填到Github的webhook里了，类型选择`Send me everything`，也可以自定义，url填上上面的url，**别忘了要在后面加上`?id={你的机器人id}`作为参数**。\n\n可见下面[如何使用](https://github.com/LeoEatle/git-webhook-wework-robot#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8)。\n\n2019-8\n1. docker镜像上传到新地址：https://cloud.docker.com/repository/docker/leoeatle/wxwork-git-robot\n\n2019-7\n1. 由于一直在维护公司内的机器人，有些改动不适用于外部使用。单独分开两个项目，不再作为两个分支管理。\n\n2019-6\n1. 重新审视之前的`dockerfile`感觉过于臃肿，不如直接把dist打包进docker，所以进行了修改\n2. 之前的腾讯云服务器没钱了，wework-robot.xyz 宣告停止服务，如有需要请自行搭建\n\n# 目前支持的事件\n## Push event 示例\n\n\u003cimg src=\"./docs/push_demo.png\" width=\"500\"\u003e\n\n## Issue event 示例\n\n\u003cimg src=\"./docs/issue_demo.png\" width=\"500\"\u003e\n\n## Merge Request 示例\n\n\u003cimg src=\"./docs/mr_demo.png\" width=\"500\"\u003e\n\nMerge Request 会有发起、合并、关闭、重新发起等几种情况，文案会有所不同。\n\n# 如何使用\n\n## Github\n\n如果是使用github，在github项目中的`Setting`中选择`Webhooks`，选择`Add Webhooks`，填写url，如`http://{{你的域名或者IP}}/github?id=7048958e-8b4b-4381-9758-af84347c240c`。\n\n![](./docs/github-demo.png)\n\n`/github`用来区分github和gitlab，这两者的处理方式不同。\n\n`id`参数代表自定义的机器人id，可以在企业微信的机器人列表中查看（注意，这个必须要自己新建的机器人才能看到），见图：\n\n![](./docs/robot-demo.jpg)\n\n## Gitlab\n\n如果是gitlab，将webhook地址改为`http://{{你的域名或者IP}}/git?id={{机器人id}}`\n\n注意这里的路由是**git**\n\n2019-10-17 更新\n现在**gitlab**路由也会指向同样的功能了，所以两种路由都可以\n\n\n# 如何部署\n\n**建议将此服务部署在自己的机器上**\n\n## 最简单的方式\n\n```bash\n# 在服务器上\ngit pull https://github.com/LeoEatle/git-webhook-wework-robot.git\nnpm install\nnpm run build\npm2 start ./dist/server.js\n```\n\n## 使用docker\n\n目前已经编译出了一份镜像文件，地址：https://cloud.docker.com/repository/docker/leoeatle/wxwork-git-robot\n```shell\n// 先登录\nsudo docker pull https://cloud.docker.com/repository/docker/leoeatle/wxwork-git-robot:latest\ndocker run -d leoeatle/wxwork-git-robot\n```\n当然，也可以使用pm2-docker来同时利用到pm2和docker。\n\n## 机器人id配置\n\n如果需要修改服务器端的默认机器人id设置，请修改项目根目录下的`.env`\n\n```conf\nPORT=8080\nNODE_ENV=development\nJWT_SECRET=your-secret-whatever\nDATABASE_URL=postgres://user:pass@localhost:5432/apidb\nCHAT_ID=82c08203-82a6-4824-8319-04a361bc0b2a # 改这里！\n```\n# 项目介绍 \u0026\u0026 开发（热烈欢迎提PR）\n\n此项目用于连接git webhook和企业微信机器人webhook，采用koa2 + typescript开发，大部分git webhook 和 企业微信机器人的数据结构已经定义好typing，如：\n\n```typescript\ninterface Repository {\n    name: string;\n    description: string;\n    homepage: string;\n    git_http_url: string;\n    git_ssh_url: string;\n    url: string;\n    visibility_level: number;\n}\n```\n\n并且项目有配置严格的tslint和lint-staged等检查。\n\n异步解决方案为`async/await`\n\ngithub事件handler: `github.ts`\ngitlab事件handler: `gilab.ts`\n\nchatRobot推送信息相关: `chat.ts`\n\n## 提交\n\n```bash\ngit add .\nnpm run commit # 让commitlint自动生成commit信息\n```\n\n# TODO\n\n* 目前gitlab只做了`push`和`merge request`事件的handler，以及只做了文字和mardown信息的推送，其余事件和其他类型的推送还需开发。\n\n* github推送目前只考虑`push` `pr` `issue`，其他有待添加\n\n* ~~为了方便其他团队甚至外面开源的使用，考虑使用docker方便自己部署。~~\n\n* ~~考虑是不是可以在配置webhook的地方直接配置机器人id，分别推送~~\n\n* ~~进一步考虑是不是可以用GUI统一管理项目和机器人id的关系~~\n\n* 考虑可以补全gitlab的typing，实在太多了，有人帮忙就好了，github已经使用了有人开源整理的typing依赖库\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://blog.soul11201.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/8514816?v=4\" width=\"100px;\" alt=\"soul11201\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003esoul11201\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/LeoEatle/git-webhook-wework-robot/issues?q=author%3Anoname007\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"https://github.com/LeoEatle/git-webhook-wework-robot/commits?author=noname007\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://liubiantao.github.io\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/3268218?v=4\" width=\"100px;\" alt=\"Haitao\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eHaitao\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/LeoEatle/git-webhook-wework-robot/issues?q=author%3Aliubiantao\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"https://github.com/LeoEatle/git-webhook-wework-robot/commits?author=liubiantao\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeoEatle%2Fgit-webhook-wework-robot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLeoEatle%2Fgit-webhook-wework-robot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeoEatle%2Fgit-webhook-wework-robot/lists"}