{"id":17137777,"url":"https://github.com/xuexb/github-bot","last_synced_at":"2025-10-06T00:18:31.718Z","repository":{"id":50265556,"uuid":"106917967","full_name":"xuexb/github-bot","owner":"xuexb","description":"GitHub 自动处理 issue、PR、releases 机器人","archived":false,"fork":false,"pushed_at":"2018-02-03T15:58:50.000Z","size":72,"stargazers_count":506,"open_issues_count":17,"forks_count":62,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T20:08:10.638Z","etag":null,"topics":["bot","github","issues","pr","pull-requests","release-notes","robot"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/xuexb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-14T10:12:03.000Z","updated_at":"2025-03-02T00:54:38.000Z","dependencies_parsed_at":"2022-08-12T21:01:25.674Z","dependency_job_id":null,"html_url":"https://github.com/xuexb/github-bot","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexb%2Fgithub-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexb%2Fgithub-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexb%2Fgithub-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexb%2Fgithub-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuexb","download_url":"https://codeload.github.com/xuexb/github-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399885,"owners_count":20932880,"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":["bot","github","issues","pr","pull-requests","release-notes","robot"],"created_at":"2024-10-14T20:07:56.114Z","updated_at":"2025-10-06T00:18:26.682Z","avatar_url":"https://github.com/xuexb.png","language":"JavaScript","readme":"# github-bot\n\ngithub 机器人：在服务端上启动一个基于 [koajs](http://koajs.com/) 的 http server ，建立一些项目的规范（如 issue 格式、 pull request 格式、配置一些指定 label 根据的 owner 、统一 git commit log 格式等），基于 [github webhooks](https://developer.github.com/webhooks/) 和 [github api](https://developer.github.com/v3/) 让机器人（通常是一个单独的帐号，如 [@jiandansousuo-bot](https://github.com/jiandansousuo-bot) ）自动处理一些事情，从而达到快速响应、自动化、解放人力的效果。\n\n[![Build Status](https://travis-ci.org/xuexb/github-bot.svg?branch=master)](https://travis-ci.org/xuexb/github-bot)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)\n[![Test Coverage](https://img.shields.io/coveralls/xuexb/github-bot/master.svg)](https://coveralls.io/r/xuexb/github-bot?branch=master)\n\n## 声明\n\n该 [仓库@xuexb/github-bot](https://github.com/xuexb/github-bot/) 是用来演示 github-bot 的基本功能，因为具体需要实现的功能，可能因项目而不同，如果你需要她，你可以 fork 并相应的添加、删除功能。以下功能是一些常用的 show case 。\n\n## 功能 - Feature\n\n### Issue\n\n- [x] 没有使用 [创建 issue](https://xuexb.github.io/github-bot/create-issue.html) 页面提交的 issue 将直接被关闭 - [示例](https://github.com/xuexb/github-bot/issues/38#issuecomment-341050970)\n- [x] 根据 [创建 issue](https://xuexb.github.io/github-bot/create-issue.html) 页面提交的 issue 类型自动打上对应 label - [示例](https://github.com/xuexb/github-bot/issues/32#event-1317962655)\n- [x] 当 issue 标记 label 为 `need demo` 时，自动回复，需要相关demo - [示例](https://github.com/xuexb/github-bot/issues/14#issuecomment-336701988)\n- [x] issue 自动 assign 给指定人员，需要配置 `package.json` 中 `config.github-bot.labelToAuthor` 映射 - [示例](https://github.com/xuexb/github-bot/issues/32#event-1317962669)\n\n### Pull Request\n\n- [x] 发 PR 时根据打的 label 自动添加指定的 reviewer ，需要配置 `package.json` 中 `config.github-bot.labelToAuthor` 映射 - [示例](https://github.com/xuexb/github-bot/pull/33#event-1320253347)\n- [x] 发 PR 时标题不规范时提醒修改，需要配置 `package.json` 中 `config.validate-commit-msg.type` 功能关键字，标题必须以 `功能关键字:` 开头 - [示例](https://github.com/xuexb/github-bot/pull/33#issuecomment-340650462)\n- [x] 发 PR 时自动根据标题的 [PR 标题规则](https://github.com/xuexb/github-bot#commit-log-和-pr-标题规则) 前缀生成对应的 label ， `feat-\u003eenhancement, fix-\u003ebug` - [示例](https://github.com/xuexb/github-bot/pull/33#event-1320253315)\n\n### Release\n\n- [x] 当往远程第一次推送新版本号时，自动列出最新版本距离上一版本的 commit log 并发布 release notes ，由于需要使用两个 tag 去对比，所以项目的第一个 tag 就不处理 - [示例](https://github.com/xuexb/github-bot/releases)\n\n## 规则 - Rules\n\n### issue 规则\n\n必须使用 [创建 issue](https://xuexb.github.io/github-bot/create-issue.html) 页面来提交 issue ，否则将直接被关闭\n\n### labels 规则\n\n- invalid - 未定义, 内容 不规范\n- need demo - 需要提供预览链接\n- need update - 需要更新修复问题\n- bug - bug\n- duplicate - 重复\n- enhancement - 新功能\n- question - 提问\n- wontfix - 不修复的问题\n\n### commit log 和 PR 标题规则\n\n所有标题必须以 `功能关键字:` 开头\n\n\u003e 参考： \u003chttp://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html\u003e\n\n功能关键字介绍如下：\n\n- feat - 新功能（feature）\n- fix - 修补bug\n- docs - 文档（documentation）\n- style - 格式（不影响代码运行的变动）\n- test - 增加测试\n- chore - 构建过程或辅助工具的变动\n- revert - 撤销\n- close - 关闭 issue\n- release - 发布版本\n\n示例：\n\n```\nclose: #1, #3\nfeat: 添加xx功能\ndocs: update install info\n```\n\n## 如何使用\n\n### 1. 创建 access tokens\n\n\u003chttps://github.com/settings/tokens\u003e （_需要在 .env 里配置_）\n\n### 2. 创建 webhook\n\nhttps://github.com/用户名/项目名/settings/hooks/new\n\n- Payload URL: www.example.com:8000\n- Content type: application/json\n- trigger: Send me everything.\n- Secret: xxx （_需要在 .env 里配置_）\n\n### 3. 开发运行\n\n```bash\nnpm install\ncp env .env\nvim .env\nnpm start\n```\n\n### 4. 部署\n\n本项目使用 [pm2](https://github.com/Unitech/pm2) 进行服务管理，发布前请先全局安装 [pm2](https://github.com/Unitech/pm2)\n\n```bash\nnpm install pm2 -g\nnpm run deploy\n```\n\n后台启动该服务后，可以通过 `pm2 ls` 来查看服务名称为 `github-bot` 的运行状态。具体 [pm2](https://github.com/Unitech/pm2) 使用，请访问：https://github.com/Unitech/pm2\n\n### 5. 日志系统说明\n\n本系统 `logger` 服务基于 [log4js](https://github.com/log4js-node/log4js-node)。\n在根目录的 `.env` 文件中有个参数 `LOG_TYPE` 默认为 `console`，参数值说明：\n\n```\nconsole - 通过 console 输出log。\nfile - 将所有相关log输出到更根目录的 `log` 文件夹中。\n```\n\n## contributors\n\n\u003e [用户贡献指南](.github/CONTRIBUTING.md)\n\n- [@yugasun](https://github.com/yugasun/)\n- [@ddhhz](https://github.com/ddhhz)\n- [@xuexb](https://github.com/xuexb/)\n\n## Liscense\n\nMIT\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexb%2Fgithub-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuexb%2Fgithub-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexb%2Fgithub-bot/lists"}