Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update install doc #277

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions docs/website/docs/getting-started/quickinstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ Reviewbot推荐使用GitHub App的方式进行集成,这样能更加方便的



在集成部署之前,我们要先了解Reviewbot需要用到的一些参数变量
在集成部署之前,我们要先了解Reviewbot需要用到的一些配置参数和配置文件
| **名称** | **是否必须** | **用途** | **获取方式** |
|:------:|:----------:|:---------:|:------:|
| ssh-secret | 必须 | 用来 拉取待检查代码 |本地生成ssh_key私钥,公钥添加到对应GitHub账号 |
| access-token | 必须 | 用来触发使用相关GitHub API |GitHub账号setting中获取 |
| githubappid | 必须 | GitHub API使用 |GitHub App中获取 |
| githubappperm | 必须 | GitHub API使用 |创建GitHub App时设置 |
| app-id | 必须 | GitHub API使用 |GitHub App中获取 |
| github-app-secret | 必须 | GitHub API使用 |创建GitHub App时设置Private Key时生成, |
| webhook-secret | 非必须 | 验证Webhook请求的有效性 |保持跟GitHub Webhook的设置保持一致,如果GitHub上没有设置就不用配置 |

其他:
| 名称 | 是否必须 | 用户| 获取方式 |
|:------:|:-------:|:------:|:------:|
| config | 非必须 | Reviewbot配置文件|在没有配置的情况下,会使用系统默认配置。配置方式参看 |
| golangci-config | 非必须 | golang语言静态检查配置|在没有配置的情况下,会使用系统默认配置。配置方式参看 |
| javapmdruleconfig | 非必须 | java pmd 检查规则|在没有配置的情况下,会使用系统默认配置。配置方式参看 |
| javastylecheckruleconfig | 非必须 | java style check 规制|在没有配置的情况下,会使用系统默认配置。配置方式参看 |
| config | 非必须 | Reviewbot配置文件|在没有配置的情况下,会使用系统默认配置。配置方式参看config/config.yaml |
| golangci-config | 非必须 | golang语言静态检查配置|在没有配置的情况下,会使用系统默认配置。配置方式参看config/linters-config/.golangci.yml |
| javapmdruleconfig | 非必须 | java pmd 检查规则|在没有配置的情况下,会使用系统默认配置。配置方式参看 [BestPractices](https://github.com/pmd/pmd/tree/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices)|
| javastylecheckruleconfig | 非必须 | java style check 规则|在没有配置的情况下,会使用系统默认配置。配置方式参看[sun_style](https://checkstyle.org/sun_style.html) |


### 安装Reviewbot服务
Expand All @@ -52,20 +52,24 @@ kubectl create configmap cm-reviewbot --from-file=config=/Users/mac/Documents/pr
``` shell
kubectl create secret generic github --from-literal=access-token=ghp_5vV5DueLdf0HyS9KlB4usWRJvcziK2eFFMS --from-literal=webhook-secret=910399965ee2cbb8fddad085dfda6c1cc263 -n reviewbot
```
2. 创建 ssh_sercret:
3. 创建 ssh_sercret:
``` shell
kubectl create secret generic ssh-secret --from-file=ssh-secret=/Users/mac/.ssh/id_rsa -n reviewbot
```
3. 创建 app-id和app-installation-id:
4. 创建 app-id和app-installation-id:
``` shell
kubectl create secret generic github-app --from-literal=app-id=957941 --from-literal=app-installation-id=53342102 -n reviewbot
```
3. 通过工程中提供的`reviewbot.yaml` 在K8S上通过命令行 `kubectl apply -f reviewbot.yaml` 进行初始化的部署 。
4. 如果镜像重新编译了,可以同通过下面命令重新设置镜像:
5. 创建 github-app-secret,pem 文件在创建GitHub App页面 生成
``` shell
kubectl create secret generic github-app-secret --from-file=github-app-secret=/Users/mac/Downloads/qiniureviewbot2.2024-07-31.private-key.pem -n reviewbot
```
6. 通过工程中提供的`reviewbot.yaml` 在K8S上通过命令行 `kubectl apply -f reviewbot.yaml` 进行初始化的部署。
7. 如果镜像重新编译了,可以同通过下面命令重新设置镜像:
``` shell
kubectl set image deployment/reviewbot reviewbot=镜像上传地址/reviewbot-新镜像:latest -n reviewbot
```
5. 启动镜像,镜像文件从configmap中读取配置。
8. 启动镜像,镜像文件从configmap中读取配置。

:::tip
如果想对Reviewbot进行其他的配置设置,根据`reviewbot.yaml`的配置要求创建对应的configmap。
Expand All @@ -77,11 +81,19 @@ kubectl set image deployment/reviewbot reviewbot=镜像上传地址/reviewbot-
docker run -p 8888:8888 --mount type=bind,target=/secrets/github_key,source=/Users/mac/.ssh/id_rsa reviewbot-customimageid -access-token=ghp_5vV5DueL4mx0HdddyS9KsWRJvcziK2eMS -webhook-secret=9bc cf10399965ee2cbb8fddad085dfda6c1cc263 -log-level 1
```

#### 测试
测试本地部署是否成功,可以通过本地模拟发送 GitHub 事件,可以借助工具 [phony](https://github.com/qiniu/reviewbot/tree/master/tools/phony)
发送webhook的 RecentDeliveries 中的 pull_request.synchronize 请求,发送命令如下
``` shell
go run . --hmac=<webhook上设置的-webhook-secret> -payload ./pull_request.synchronize 请求.json --event=pull_request --address http://部署的机器或容器ip:8888/hook
```

#### 设置外网映射
如果是通过GitHub App的方式进行集成,需要将部署好的Reviewbot服务,映射到外网ip或者域名上面,使GitHub能访问到。

### 创建GitHub App
1. 创建GitHub App,在Settings 》 Developer settings》 创建一个GitHub App,记录GitHub App ID。
1. 创建GitHub App,在Settings 》 Developer settings》 创建一个GitHub App,记录GitHub App ID,在Private keys配置项中过生成Private key,同时下载保存xxx.pem文件
文件。
2. 设置权限
* Repository permissions
* Checks: Read & write
Expand Down
Loading