{"id":19340388,"url":"https://github.com/tim9liu9/python_webhook","last_synced_at":"2025-04-23T02:31:25.066Z","repository":{"id":80219969,"uuid":"113943130","full_name":"Tim9Liu9/python_webhook","owner":"Tim9Liu9","description":"用python实现的码云webhook自动部署脚本,能用在python2.6、2.7上，还能用于python3上，不用安装其他python包。","archived":false,"fork":false,"pushed_at":"2017-12-15T02:28:44.000Z","size":16,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T06:51:15.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tim9Liu9.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-12-12T04:25:04.000Z","updated_at":"2024-07-22T04:01:26.000Z","dependencies_parsed_at":"2023-04-24T12:24:51.598Z","dependency_job_id":null,"html_url":"https://github.com/Tim9Liu9/python_webhook","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/Tim9Liu9%2Fpython_webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tim9Liu9%2Fpython_webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tim9Liu9%2Fpython_webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tim9Liu9%2Fpython_webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tim9Liu9","download_url":"https://codeload.github.com/Tim9Liu9/python_webhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357628,"owners_count":21417317,"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-11-10T03:26:20.070Z","updated_at":"2025-04-23T02:31:25.055Z","avatar_url":"https://github.com/Tim9Liu9.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python_webhook\n  本人公司在开源中国[码云](https://gitee.com)上的webhook部署脚本，是本人采用Tornado实现的，因为公司的服务器是centos6.8，自带python2.6.6，Tornado必要要python2.7或python3环境，因此要安装起来对于没有python基础的朋友是个麻烦事情。下面2个脚本不用安装任何包，就可以在centosOS6.x、centOS7.x、ubuntu14.04、ubuntu16.04上运行，简单方便。  \n  \n    \n#### SimpleWebHook.py : 支持python2.6、python2.7不支持python3.x\n    用python2.x的SimpleHTTPServer实现的webhook自动部署脚本。可以用于码云的webhook，也可以修改成github上使用。  \n- - - \n#### WebHookAll.py : 支持python2.x、python3.x （推荐使用）\n    用python自带的WSGI(wsgiref)实现的webhook自动部署脚本。主要用于码云的webhook，也可以修改成github上使用。 \n\n  \n- - -  \n  \n### 部署步骤\n===\n\n\u003e Python 使用 WebHookAll.py 实现 WebHook 自动部署 Git 项目\n\n为了方便开发测试或项目部署至服务器不那么繁琐，搞一个自动部署的小轮子也是非常有必要的。\n\n这里需要涉及到 https://gitee.com 码云 项目托管平台(也可以用 Github 平台)，Linux服务器的自带的python。\n\n同时配置项目托管平台的个人私钥或项目公钥，保证 `git pull` 能直接拉取。  [码云官方文档](http://git.mydoc.io/?t=154711)  ; Linux记得开启请求的端口号，这里是：1010，防止防火墙的屏蔽。如果是阿里云，记得在阿里云控制台的实例的安全组里面添加入站tcp端口：1010。  \n\n## 安装\n\n1.下载或克隆此项目: 克隆的时候最好使用ssh协议\n\n```shell\ngit clone git@github.com:Tim9Liu9/python_webhook.git\n```\n\n\n## 修改配置\n\n1.修改 `WebHookAll.py` 中变量：\n\n```python\n    # 此处修改端口号\n    PORT = 1010\n    # 此处修改码云上设置的密码\n    PASSWORD = \"timliu1010\"\n    # git pull要更新代码的目录\n    PATH = \"/data/www/webhook/python_webhook/\"\n```\n\n\n## 启动\n\n1.运行python脚本开启后台进程运行\n\n```shell\nsetsid python /data/sh/WebHookAll.py \u0026\n```\n\n## 配置 gitee.com 项目里面 \n\n1.`url` 填你的域名 `http://xxx.xxx.com:1010`\n\n2.`密码` 填 `timliu1010`\n\n## 测试\n\n1.本地于服务器自动部署的git项目中使用 git 提交更新一下代码\n\n```shell\ntouch test.md\ngit push 提交到服务器\n```\n\n2.查看服务器上自动部署的git项目中是否存在 `test.md`\n\ndone.\n  \n- - -    \n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftim9liu9%2Fpython_webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftim9liu9%2Fpython_webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftim9liu9%2Fpython_webhook/lists"}